Valkyrie-support/Valkyrie/Commands/RemoveCategoryCommand.cs

41 lines
1.3 KiB
C#
Raw Normal View History

2023-08-02 05:16:21 -07:00
using DSharpPlus.Entities;
using DSharpPlus.SlashCommands.Attributes;
using DSharpPlus.SlashCommands;
using System.Threading.Tasks;
namespace Valkyrie.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);
}
}
}