2022-04-18 22:52:03 +12:00
|
|
|
|
using System;
|
2024-12-26 18:36:20 +13:00
|
|
|
|
using System.ComponentModel;
|
2022-02-21 21:40:09 +13:00
|
|
|
|
using System.Threading.Tasks;
|
2024-12-26 18:36:20 +13:00
|
|
|
|
using DSharpPlus.Commands;
|
|
|
|
|
using DSharpPlus.Commands.ContextChecks;
|
|
|
|
|
using DSharpPlus.Commands.Processors.SlashCommands;
|
2022-02-21 21:40:09 +13:00
|
|
|
|
using DSharpPlus.Entities;
|
2024-12-26 18:57:41 +13:00
|
|
|
|
using DSharpPlus.Exceptions;
|
2022-02-21 21:40:09 +13:00
|
|
|
|
|
2022-08-21 19:34:11 +12:00
|
|
|
|
namespace SupportChild.Commands;
|
|
|
|
|
|
2024-12-26 18:36:20 +13:00
|
|
|
|
public class UnblacklistCommand
|
2022-02-21 21:40:09 +13:00
|
|
|
|
{
|
2024-12-26 18:36:20 +13:00
|
|
|
|
[RequireGuild]
|
|
|
|
|
[Command("unblacklist")]
|
|
|
|
|
[Description("Unblacklists a user from opening tickets.")]
|
|
|
|
|
public async Task OnExecute(SlashCommandContext command, [Parameter("user")][Description("User to remove from blacklist.")] DiscordUser user)
|
2024-10-29 22:10:37 +13:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!Database.Unblacklist(user.Id))
|
|
|
|
|
{
|
2024-12-26 18:36:20 +13:00
|
|
|
|
await command.RespondAsync(new DiscordEmbedBuilder
|
2024-10-29 22:10:37 +13:00
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Red,
|
|
|
|
|
Description = user.Mention + " is not blacklisted."
|
|
|
|
|
}, true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-02-21 21:40:09 +13:00
|
|
|
|
|
2024-12-26 18:36:20 +13:00
|
|
|
|
await command.RespondAsync(new DiscordEmbedBuilder
|
2024-10-29 22:10:37 +13:00
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Green,
|
2024-12-27 01:21:37 +13:00
|
|
|
|
Description = "Unblocked " + user.Mention + " from opening new tickets."
|
2024-10-29 22:10:37 +13:00
|
|
|
|
}, true);
|
2022-02-21 21:40:09 +13:00
|
|
|
|
|
2024-12-26 18:57:41 +13:00
|
|
|
|
try
|
2024-10-29 22:10:37 +13:00
|
|
|
|
{
|
2024-12-26 18:57:41 +13:00
|
|
|
|
// Log it if the log channel exists
|
|
|
|
|
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
2024-10-29 22:10:37 +13:00
|
|
|
|
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Green,
|
2024-12-27 01:21:37 +13:00
|
|
|
|
Description = user.Mention + " was unblocked from opening tickets by " + command.User.Mention + "."
|
2024-10-29 22:10:37 +13:00
|
|
|
|
});
|
|
|
|
|
}
|
2024-12-26 18:57:41 +13:00
|
|
|
|
catch (NotFoundException)
|
|
|
|
|
{
|
|
|
|
|
Logger.Error("Could not find the log channel.");
|
|
|
|
|
}
|
2024-10-29 22:10:37 +13:00
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
2024-12-26 18:36:20 +13:00
|
|
|
|
await command.RespondAsync(new DiscordEmbedBuilder
|
2024-10-29 22:10:37 +13:00
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Red,
|
|
|
|
|
Description = "Error occured while removing " + user.Mention + " from blacklist."
|
|
|
|
|
}, true);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-19 23:38:59 +12:00
|
|
|
|
}
|