aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar F4zii <[email protected]>2020-02-21 21:10:00 +0200
committerGravatar F4zii <[email protected]>2020-02-21 21:10:00 +0200
commit7fd9225d964ff90f972afd1e780ebb26df1a365c (patch)
tree2db878d61a8d2966195546aafc98967f16ee8d4d
parentCommand suggestion message reformat. (diff)
Handling and logging CommandError
the CommandError exception was ignored, We now catch the exception to handle and log the event Also added a little code reformat
-rw-r--r--bot/cogs/error_handler.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/bot/cogs/error_handler.py b/bot/cogs/error_handler.py
index 39b868e62..19d6e6946 100644
--- a/bot/cogs/error_handler.py
+++ b/bot/cogs/error_handler.py
@@ -108,16 +108,20 @@ class ErrorHandler(Cog):
similar_command_name = similar_command_data[0]
similar_command = self.bot.get_command(similar_command_name)
- with contextlib.suppress(CommandError):
- if similar_command.can_run(ctx):
- misspelled_content = ctx.message.content
- e = Embed()
- e.set_author(name="Did you mean:", icon_url=Icons.questionmark)
- e.description = f"{misspelled_content.replace(command_name, similar_command_name)}"
- await ctx.send(
- embed=e,
- delete_after=7.0
- )
+ log_msg = "Cancelling attempt to suggest a command due to failed checks."
+ try:
+ if not similar_command.can_run(ctx):
+ log.debug(log_msg)
+ return
+ except CommandError as cmd_error:
+ log.debug(log_msg)
+ await self.on_command_error(ctx, cmd_error)
+
+ misspelled_content = ctx.message.content
+ e = Embed()
+ e.set_author(name="Did you mean:", icon_url=Icons.questionmark)
+ e.description = f"{misspelled_content.replace(command_name, similar_command_name)}"
+ await ctx.send(embed=e, delete_after=7.0)
elif isinstance(e, BadArgument):
await ctx.send(f"Bad argument: {e}\n")