Beispiel #1
0
 protected async Task RespondError(string message)
 {
     await Ctx.CreateResponseAsync(DSharpPlus.InteractionResponseType.ChannelMessageWithSource,
                                   new DiscordInteractionResponseBuilder()
                                   .AddEmbed(CommandModule.ErrorBase()
                                             .WithDescription(message)));
 }
Beispiel #2
0
        private static async Task ArgumentResponderAsync(CommandErrorEventArgs args)
        {
            var embed = CommandModule.ErrorBase()
                        .WithDescription($"Invalid Arguments");

            await args.Context.RespondAsync(embed : embed);
        }
Beispiel #3
0
        private static async Task ChecksFailedResponderAsync(CommandErrorEventArgs args, ChecksFailedException e)
        {
            var embed = CommandModule.ErrorBase()
                        .WithDescription($"Invalid Permissions: {e.Message}");

            await args.Context.RespondAsync(embed : embed);
        }
Beispiel #4
0
        public static async Task RespondCommandDisabledAsync(DiscordChannel executionChannel, string prefix)
        {
            var embed = CommandModule.ErrorBase()
                        .WithTitle("Command Disabled")
                        .WithDescription($"Use {prefix}help to see all enabled commands.");

            await executionChannel.SendMessageAsync(embed : embed);
        }
Beispiel #5
0
        public static async Task RespondErrorAsync(CommandsNextExtension cnext, CommandErrorEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            if (e.Exception is ChecksFailedException cfex)
            {
                await ChecksFailedResponderAsync(e, cfex).ConfigureAwait(false);
            }
            else if (e.Exception is ArgumentException)
            {
                await ArgumentResponderAsync(e).ConfigureAwait(false);
            }
            else
            {
                var embed = CommandModule.ErrorBase()
                            .WithDescription($"An unhadled error occoured: {e.Exception.Message}");

                await e.Context.RespondAsync(embed : embed).ConfigureAwait(false);
            }
        }