private async Task Commands_CommandErrored(CommandErrorEventArgs e) { loadJSON(); // let's log the error details e.Context.Client.DebugLogger.LogMessage(LogLevel.Error, "SWGOHBot", $"{e.Context.User.Username} tried executing '{e.Command?.QualifiedName ?? "<unknown command>"}' but it errored: {e.Exception.GetType()}: {e.Exception.Message ?? "<no message>"}", DateTime.Now); // let's check if the error is a result of lack of required permissions if (e.Exception is ChecksFailedException ex) { // yes, the user lacks required permissions, let them know var emoji = DiscordEmoji.FromName(e.Context.Client, ":no_entry:"); // let's wrap the response into an embed var embed = new DiscordEmbedBuilder { Title = "Access denied", Description = $"{emoji} You do not have the permissions required to execute this command.", Color = new DiscordColor(0xFF0000) // red }; await e.Context.RespondAsync("", embed : embed); } if (e.Exception is ArgumentException) { String s = ""; if (!AllyCode.IsValid(Convert.ToUInt32(e.Exception.Data["allycode"]))) { s = $":scream:The ally code given is invalid, please try again with a valid ally code."; } else { } var emoji = DiscordEmoji.FromName(e.Context.Client, ":no_entry:"); if (e.Exception.Data.Keys.Count > 0) { for (int i = 0; i < e.Exception.Data.Keys.Count; i++) { if (e.Exception.Data[i] == null) { s += "I need a value for " + e.Exception.Data[i]; } } } else { //s = $":scream:You haven't told me anything. I need to know who I'm looking for and for whom\nTry {cfgjson.CommandPrefix}reqs <character> <ally code>"; } // let's wrap the response into an embed var embed = new DiscordEmbedBuilder { Title = "Jar Jar", Description = s, //$"{emoji} I need to know who you want me to look for. Example: thrawn", Color = new DiscordColor(0xFF0000) // red }; await e.Context.RespondAsync("", embed : embed); } }
private async Task Commands_CommandErrored(CommandErrorEventArgs e) { loadJSON(); // let's log the error details e.Context.Client.DebugLogger.LogMessage(LogLevel.Error, "SWGOHBot", $"{e.Context.User.Username} tried executing '{e.Command?.QualifiedName ?? "<unknown command>"}' but it errored: {e.Exception.GetType()}: {e.Exception.Message ?? "<no message>"}", DateTime.Now); // let's check if the error is a result of lack of required permissions if (e.Exception is ChecksFailedException ex) { // yes, the user lacks required permissions, let them know var emoji = DiscordEmoji.FromName(e.Context.Client, ":no_entry:"); // let's wrap the response into an embed var embed = new DiscordEmbedBuilder { Title = "Access denied", Description = $"{emoji} You do not have the permissions required to execute this command.", Color = new DiscordColor(0xFF0000) // red }; await e.Context.RespondAsync("", embed : embed); } if (e.Exception is NotFoundException nfe) { String s = $":scream:The command must be ran with either 2 arguements or a Discord user."; // let's wrap the response into an embed var embed = new DiscordEmbedBuilder { Title = "Uh Oh! Looks like there was a problem!", Description = s, //$"{emoji} I need to know who you want me to look for. Example: thrawn", Color = new DiscordColor(0xFF0000) // red }; await e.Context.RespondAsync("", embed : embed); } if (e.Exception is ArgumentException) { String s = ""; if (!AllyCode.IsValid(Convert.ToUInt32(e.Exception.Data["allycode"]))) { s = $":scream:The command must be ran with either 2 arguements or a Discord user."; } else { } var emoji = DiscordEmoji.FromName(e.Context.Client, ":no_entry:"); // let's wrap the response into an embed var embed = new DiscordEmbedBuilder { Title = "Uh Oh! Looks like there was a problem!", Description = s, //$"{emoji} I need to know who you want me to look for. Example: thrawn", Color = new DiscordColor(0xFF0000) // red }; await e.Context.RespondAsync("", embed : embed); } }