diff options
| author | 2021-04-12 21:49:45 +0100 | |
|---|---|---|
| committer | 2021-04-14 05:22:37 +0100 | |
| commit | fbe8e0a5bf4ffb4443a54588b7f55f25306eee6f (patch) | |
| tree | b455db8577d1746d7623e7b891a8549432246eea | |
| parent | Merge pull request #681 from python-discord/vcokltfre/feat/ping (diff) | |
fix: display help for the correct command when an error occurs in timed
| -rw-r--r-- | bot/exts/evergreen/error_handler.py | 10 | ||||
| -rw-r--r-- | bot/exts/evergreen/timed.py | 4 | 
2 files changed, 11 insertions, 3 deletions
| diff --git a/bot/exts/evergreen/error_handler.py b/bot/exts/evergreen/error_handler.py index 28902503..8db49748 100644 --- a/bot/exts/evergreen/error_handler.py +++ b/bot/exts/evergreen/error_handler.py @@ -46,6 +46,11 @@ class CommandErrorHandler(commands.Cog):              logging.debug(f"Command {ctx.command} had its error already handled locally; ignoring.")              return +        parent_command = "" +        if subctx := getattr(ctx, "subcontext", None): +            parent_command = f"{ctx.command} " +            ctx = subctx +          error = getattr(error, 'original', error)          logging.debug(              f"Error Encountered: {type(error).__name__} - {str(error)}, " @@ -63,8 +68,9 @@ class CommandErrorHandler(commands.Cog):          if isinstance(error, commands.UserInputError):              self.revert_cooldown_counter(ctx.command, ctx.message) +            usage = f"```{ctx.prefix}{parent_command}{ctx.command} {ctx.command.signature}```"              embed = self.error_embed( -                f"Your input was invalid: {error}\n\nUsage:\n```{ctx.prefix}{ctx.command} {ctx.command.signature}```" +                f"Your input was invalid: {error}\n\nUsage:{usage}"              )              await ctx.send(embed=embed)              return @@ -95,7 +101,7 @@ class CommandErrorHandler(commands.Cog):              self.revert_cooldown_counter(ctx.command, ctx.message)              embed = self.error_embed(                  "The argument you provided was invalid: " -                f"{error}\n\nUsage:\n```{ctx.prefix}{ctx.command} {ctx.command.signature}```" +                f"{error}\n\nUsage:\n```{ctx.prefix}{parent_command}{ctx.command} {ctx.command.signature}```"              )              await ctx.send(embed=embed)              return diff --git a/bot/exts/evergreen/timed.py b/bot/exts/evergreen/timed.py index 635ccb32..5f177fd6 100644 --- a/bot/exts/evergreen/timed.py +++ b/bot/exts/evergreen/timed.py @@ -21,7 +21,9 @@ class TimedCommands(commands.Cog):          """Time the command execution of a command."""          new_ctx = await self.create_execution_context(ctx, command) -        if not new_ctx.command: +        ctx.subcontext = new_ctx + +        if not ctx.subcontext.command:              help_command = f"{ctx.prefix}help"              error = f"The command you are trying to time doesn't exist. Use `{help_command}` for a list of commands." | 
