Skip to content

Commit

Permalink
better error response for failing checks. i do not like the implement…
Browse files Browse the repository at this point in the history
…ation, but it works, and a better implementation is unwieldy and unpleasant
  • Loading branch information
Foxite committed Sep 1, 2024
1 parent 0b1c591 commit 2b37d57
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions HighlightBot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async Task ReportCommandError(CommandContext e, Exception exception) {

return eventArgs.Exception switch {
CommandNotFoundException => eventArgs.Context.RespondAsync("Unknown command."),
ChecksFailedException => eventArgs.Context.RespondAsync("Checks failed 🙁"),
ChecksFailedException => eventArgs.Context.RespondAsync("All commands must be used within a server."),
ArgumentException { Message: "Could not find a suitable overload for the command." } => eventArgs.Context.RespondAsync("Invalid arguments."),
_ => ReportCommandError(eventArgs.Context, eventArgs.Exception),
};
Expand All @@ -144,7 +144,7 @@ async Task ReportSlashCommandError(InteractionContext e, Exception exception) {
Host.Services.GetRequiredService<ILogger<Program>>().LogError(eventArgs.Exception, "Error executing slash command");

return eventArgs.Exception switch {
SlashExecutionChecksFailedException => eventArgs.Context.CreateResponseAsync("Checks failed 🙁"),
SlashExecutionChecksFailedException => eventArgs.Context.CreateResponseAsync("All commands must be used within a server."),
ArgumentException { Message: "Could not find a suitable overload for the command." } => eventArgs.Context.CreateResponseAsync("Invalid arguments."),
_ => ReportSlashCommandError(eventArgs.Context, eventArgs.Exception),
};
Expand Down

0 comments on commit 2b37d57

Please sign in to comment.