Breadcraft-Support/Breadcraft/Commands/RemoveCategoryCommand.cs

41 lines
1.1 KiB
C#
Raw Normal View History

2023-01-26 03:42:11 -08:00
using System.Threading.Tasks;
using DSharpPlus.Entities;
using DSharpPlus.SlashCommands;
using DSharpPlus.SlashCommands.Attributes;
namespace Breadcraft.Commands;
public class RemoveCategoryCommand : ApplicationCommandModule
{
[SlashRequireGuild]
[SlashCommand("removecategory", "Removes the ability for users to open tickets in a specific category.")]
public async Task OnExecute(InteractionContext command, [Option("Category", "The category to remove.")] DiscordChannel channel)
{
if (!Database.TryGetCategory(channel.Id, out Database.Category _))
{
await command.CreateResponseAsync(new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "That category is not registered."
}, true);
return;
}
if (Database.RemoveCategory(channel.Id))
{
await command.CreateResponseAsync(new DiscordEmbedBuilder
{
Color = DiscordColor.Green,
Description = "Category removed."
}, true);
}
else
{
await command.CreateResponseAsync(new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "Error: Failed removing the category from the database."
}, true);
}
}
}