2024-12-26 05:36:20 +00:00
|
|
|
using System.ComponentModel;
|
2024-10-29 09:10:37 +00:00
|
|
|
using System.Threading.Tasks;
|
2024-12-26 05:36:20 +00:00
|
|
|
using DSharpPlus.Commands;
|
|
|
|
using DSharpPlus.Commands.ContextChecks;
|
|
|
|
using DSharpPlus.Commands.Processors.SlashCommands;
|
2022-08-21 07:34:11 +00:00
|
|
|
using DSharpPlus.Entities;
|
2024-12-26 12:21:37 +00:00
|
|
|
using DSharpPlus.Exceptions;
|
2022-08-21 07:34:11 +00:00
|
|
|
|
|
|
|
namespace SupportChild.Commands;
|
|
|
|
|
2024-12-26 05:36:20 +00:00
|
|
|
public class RemoveCategoryCommand
|
2022-08-21 07:34:11 +00:00
|
|
|
{
|
2024-12-26 05:36:20 +00:00
|
|
|
[RequireGuild]
|
|
|
|
[Command("removecategory")]
|
|
|
|
[Description("Removes the ability for users to open tickets in a specific category.")]
|
|
|
|
public async Task OnExecute(SlashCommandContext command,
|
2024-12-26 12:21:37 +00:00
|
|
|
[Parameter("category")][Description("The category to remove.")] DiscordChannel category)
|
2024-10-29 09:10:37 +00:00
|
|
|
{
|
2024-12-26 12:21:37 +00:00
|
|
|
if (!Database.TryGetCategory(category.Id, out Database.Category _))
|
2024-10-29 09:10:37 +00:00
|
|
|
{
|
2024-12-26 05:36:20 +00:00
|
|
|
await command.RespondAsync(new DiscordEmbedBuilder
|
2024-10-29 09:10:37 +00:00
|
|
|
{
|
|
|
|
Color = DiscordColor.Red,
|
|
|
|
Description = "That category is not registered."
|
|
|
|
}, true);
|
|
|
|
return;
|
|
|
|
}
|
2022-08-21 07:34:11 +00:00
|
|
|
|
2024-12-26 12:21:37 +00:00
|
|
|
if (Database.RemoveCategory(category.Id))
|
2024-10-29 09:10:37 +00:00
|
|
|
{
|
2024-12-26 05:36:20 +00:00
|
|
|
await command.RespondAsync(new DiscordEmbedBuilder
|
2024-10-29 09:10:37 +00:00
|
|
|
{
|
|
|
|
Color = DiscordColor.Green,
|
|
|
|
Description = "Category removed."
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-12-26 05:36:20 +00:00
|
|
|
await command.RespondAsync(new DiscordEmbedBuilder
|
2024-10-29 09:10:37 +00:00
|
|
|
{
|
|
|
|
Color = DiscordColor.Red,
|
|
|
|
Description = "Error: Failed removing the category from the database."
|
|
|
|
}, true);
|
|
|
|
}
|
2024-12-26 12:21:37 +00:00
|
|
|
|
2024-12-27 07:17:14 +00:00
|
|
|
await LogChannel.Success("`" + category.Name + "` was removed by " + command.User.Mention + ".");
|
2024-10-29 09:10:37 +00:00
|
|
|
}
|
2022-08-21 07:34:11 +00:00
|
|
|
}
|