automatically remove messages in old text command format

This commit is contained in:
13xforever
2025-03-25 19:39:47 +05:00
parent f93c17fe2d
commit 72fe53051c
2 changed files with 10 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
using System.Net;
using DSharpPlus.Commands.EventArgs;
using DSharpPlus.Commands.Exceptions;
using DSharpPlus.Commands.Processors.TextCommands;
using DSharpPlus.Exceptions;
namespace CompatBot.Commands.Processors;
@@ -10,9 +11,15 @@ internal static class CommandErroredHandler
// CommandsExtension.DefaultCommandErrorHandlerAsync()
public static async Task OnError(CommandsExtension sender, CommandErroredEventArgs eventArgs)
{
StringBuilder stringBuilder = new();
StringBuilder stringBuilder = new();
DiscordMessageBuilder messageBuilder = new();
if (eventArgs is { Exception: CommandNotFoundException, Context: TextCommandContext tctx })
{
await tctx.Message.DeleteAsync().ConfigureAwait(false);
return;
}
// Error message
stringBuilder.Append(eventArgs.Exception switch
{

View File

@@ -145,6 +145,8 @@ internal static class Program
Config.CommandPrefix,
Config.AutoRemoveCommandPrefix
).ResolvePrefixAsync,
IgnoreBots = true,
EnableCommandNotFoundException = true,
});
var appCommandProcessor = new SlashCommandProcessor(new()
{