diff options
| author | 2020-11-07 18:45:51 +0200 | |
|---|---|---|
| committer | 2020-11-07 18:46:12 +0200 | |
| commit | d2c1b270cebfcca5f081daceeda3dadfa28313e1 (patch) | |
| tree | 1cbf748b9da2e57c34007ced6beefdfaf98d3265 | |
| parent | Merge branch 'master' into help-disabled-command (diff) | |
Catch CommandError for help command can_run await
| -rw-r--r-- | bot/exts/info/help.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/bot/exts/info/help.py b/bot/exts/info/help.py index 5e0651f8a..44bff1f88 100644 --- a/bot/exts/info/help.py +++ b/bot/exts/info/help.py @@ -5,7 +5,7 @@ from contextlib import suppress from typing import List, Union from discord import Colour, Embed -from discord.ext.commands import Bot, Cog, Command, Context, Group, HelpCommand +from discord.ext.commands import Bot, Cog, Command, Context, Group, HelpCommand, DisabledCommand, CommandError from fuzzywuzzy import fuzz, process from fuzzywuzzy.utils import full_process @@ -173,12 +173,16 @@ class CustomHelpCommand(HelpCommand): if aliases: command_details += f"**Can also use:** {aliases}\n\n" - # when command is disabled, show message about it + # when command is disabled, show message about it, + # when other CommandError instance is raised, log warning about it # otherwise check if the user is allowed to run this command - if not command.enabled: + try: + if not await command.can_run(self.context): + command_details += "***You cannot run this command.***\n\n" + except DisabledCommand: command_details += "***This command is disabled.***\n\n" - elif not await command.can_run(self.context): - command_details += "***You cannot run this command.***\n\n" + except CommandError as e: + log.warning(f"An exception raised when trying to check {command.name} command running permission: {e}") command_details += f"*{command.help or 'No details provided.'}*\n" embed.description = command_details |