diff options
| -rw-r--r-- | bot/exts/backend/error_handler.py | 32 | 
1 files changed, 16 insertions, 16 deletions
| diff --git a/bot/exts/backend/error_handler.py b/bot/exts/backend/error_handler.py index f3d8537bd..fa3f706e6 100644 --- a/bot/exts/backend/error_handler.py +++ b/bot/exts/backend/error_handler.py @@ -177,25 +177,25 @@ class ErrorHandler(Cog):          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) - -        log_msg = "Cancelling attempt to suggest a command due to failed checks." -        try: -            if not await similar_command.can_run(ctx): +        if 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) + +            log_msg = "Cancelling attempt to suggest a command due to failed checks." +            try: +                if not await similar_command.can_run(ctx): +                    log.debug(log_msg) +                    return +            except errors.CommandError as cmd_error:                  log.debug(log_msg) +                await self.on_command_error(ctx, cmd_error)                  return -        except errors.CommandError as cmd_error: -            log.debug(log_msg) -            await self.on_command_error(ctx, cmd_error) -            return -        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, 1)}" -        await ctx.send(embed=e, delete_after=10.0) +            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, 1)}" +            await ctx.send(embed=e, delete_after=10.0)      async def handle_user_input_error(self, ctx: Context, e: errors.UserInputError) -> None:          """ | 
