aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar F4zii <[email protected]>2020-02-22 13:30:41 +0200
committerGravatar F4zii <[email protected]>2020-02-22 13:30:41 +0200
commit093fb2c7a234dbea171f439871f082fcf432b524 (patch)
treea3fc0ac1f279e043d7558f5bf7f0c552e6161e09
parentOnly replace the misspelt command, and not the whole occurrences of it (diff)
Handling CommandError and Optimization
After CommandError was catched, the embed was sent, now we return after the exception was catched Modified the way raw_commands are collected
-rw-r--r--bot/cogs/error_handler.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/bot/cogs/error_handler.py b/bot/cogs/error_handler.py
index a642c3b7e..687eee9c7 100644
--- a/bot/cogs/error_handler.py
+++ b/bot/cogs/error_handler.py
@@ -98,12 +98,10 @@ class ErrorHandler(Cog):
# No similar tag found, or tag on cooldown -
# searching for a similar command
- raw_commands = [
- (cmd.name, *cmd.aliases)
- for cmd in self.bot.walk_commands()
- if not cmd.hidden
- ]
- raw_commands = [c for data in raw_commands for c in data]
+ raw_commands = []
+ for cmd in self.bot.walk_commands():
+ if not cmd.hidden:
+ raw_commands += (cmd.name, *cmd.aliases)
similar_command_data = difflib.get_close_matches(command_name, raw_commands, 1)
similar_command_name = similar_command_data[0]
similar_command = self.bot.get_command(similar_command_name)
@@ -116,6 +114,7 @@ class ErrorHandler(Cog):
except CommandError as cmd_error:
log.debug(log_msg)
await self.on_command_error(ctx, cmd_error)
+ return
misspelled_content = ctx.message.content
e = Embed()