From 6280fd9c2816f0ccf35988fe80242cc26e8dc0fa Mon Sep 17 00:00:00 2001 From: Michael H Date: Sat, 27 Jul 2019 02:36:21 -0400 Subject: [PATCH] disabled help hideaways (#2892) * disabled help hideaways * can_see fix --- changelog.d/2863.fix.rst | 1 + changelog.d/2892.enhance.rst | 1 + changelog.d/2892.fix.1.rst | 1 + redbot/core/commands/commands.py | 2 +- redbot/core/commands/help.py | 9 ++++----- 5 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 changelog.d/2863.fix.rst create mode 100644 changelog.d/2892.enhance.rst create mode 100644 changelog.d/2892.fix.1.rst diff --git a/changelog.d/2863.fix.rst b/changelog.d/2863.fix.rst new file mode 100644 index 000000000..c0bd0ecda --- /dev/null +++ b/changelog.d/2863.fix.rst @@ -0,0 +1 @@ +Help properly hides disabled commands. \ No newline at end of file diff --git a/changelog.d/2892.enhance.rst b/changelog.d/2892.enhance.rst new file mode 100644 index 000000000..67aa8ea2f --- /dev/null +++ b/changelog.d/2892.enhance.rst @@ -0,0 +1 @@ +Red's Help Formatter is now considered to have a stable API. \ No newline at end of file diff --git a/changelog.d/2892.fix.1.rst b/changelog.d/2892.fix.1.rst new file mode 100644 index 000000000..f24241cc7 --- /dev/null +++ b/changelog.d/2892.fix.1.rst @@ -0,0 +1 @@ +``Command.can_see`` now works as intended for disabled commands \ No newline at end of file diff --git a/redbot/core/commands/commands.py b/redbot/core/commands/commands.py index 82afe3404..7c9e573e3 100644 --- a/redbot/core/commands/commands.py +++ b/redbot/core/commands/commands.py @@ -328,7 +328,7 @@ class Command(CogCommandMixin, commands.Command): can_run = await self.can_run( ctx, check_all_parents=True, change_permission_state=False ) - except commands.CheckFailure: + except (commands.CheckFailure, commands.errors.DisabledCommand): return False else: if can_run is False: diff --git a/redbot/core/commands/help.py b/redbot/core/commands/help.py index 9b5c405c3..0d457b3c4 100644 --- a/redbot/core/commands/help.py +++ b/redbot/core/commands/help.py @@ -1,7 +1,6 @@ # This is a full replacement of discord.py's help command -# Signatures are not guaranteed to be unchanging in this file. -# At a later date when this is more set in stone, this warning will be removed. -# At said later date, there should also be things added to support extra formatter +# +# At a later date, there should be things added to support extra formatter # registration from 3rd party cogs. # # This exists due to deficiencies in discord.py which conflict @@ -441,14 +440,14 @@ class RedHelpFormatter: for obj in objects: if verify_checks and not show_hidden: # Default Red behavior, can_see includes a can_run check. - if await obj.can_see(ctx): + if await obj.can_see(ctx) and getattr(obj, "enabled", True): yield obj elif verify_checks: try: can_run = await obj.can_run(ctx) except discord.DiscordException: can_run = False - if can_run: + if can_run and getattr(obj, "enabled", True): yield obj elif not show_hidden: if not getattr(obj, "hidden", False): # Cog compatibility