2024-12-26 05:36:20 +00:00
|
|
|
|
using System.ComponentModel;
|
2024-12-27 07:17:14 +00:00
|
|
|
|
using System.Globalization;
|
2024-12-26 05:36:20 +00:00
|
|
|
|
using DSharpPlus.Entities;
|
2022-02-21 08:40:09 +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;
|
2024-12-26 12:21:37 +00:00
|
|
|
|
using DSharpPlus.Exceptions;
|
2022-02-21 08:40:09 +00:00
|
|
|
|
|
2022-08-21 07:34:11 +00:00
|
|
|
|
namespace SupportChild.Commands;
|
2022-02-21 08:40:09 +00:00
|
|
|
|
|
2024-12-26 05:36:20 +00:00
|
|
|
|
public class RemoveMessageCommand
|
2022-08-21 07:34:11 +00:00
|
|
|
|
{
|
2024-12-26 05:36:20 +00:00
|
|
|
|
[RequireGuild]
|
|
|
|
|
[Command("removemessage")]
|
|
|
|
|
[Description("Removes a message from the 'say' command.")]
|
|
|
|
|
public async Task OnExecute(SlashCommandContext command,
|
|
|
|
|
[Parameter("identifier")][Description("The identifier word used in the /say command.")] string identifier)
|
2024-10-29 09:10:37 +00:00
|
|
|
|
{
|
2024-12-27 07:17:14 +00:00
|
|
|
|
if (!Database.TryGetMessage(identifier.ToLower(CultureInfo.InvariantCulture), out Database.Message _))
|
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 = "There is no message with that identifier."
|
|
|
|
|
}, true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-02-21 08:40:09 +00:00
|
|
|
|
|
2024-10-29 09:10:37 +00:00
|
|
|
|
if (Database.RemoveMessage(identifier))
|
|
|
|
|
{
|
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 = "Message 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 message from the database."
|
|
|
|
|
}, true);
|
|
|
|
|
}
|
2024-12-26 12:21:37 +00:00
|
|
|
|
|
2024-12-27 07:17:14 +00:00
|
|
|
|
await LogChannel.Success("`" + identifier + "` was removed from the /say command by " + command.User.Mention + ".");
|
2024-10-29 09:10:37 +00:00
|
|
|
|
}
|
2022-05-19 11:38:59 +00:00
|
|
|
|
}
|