aboutsummaryrefslogtreecommitdiff
path: root/discord/ext/commands/help.py
diff options
context:
space:
mode:
authorRiley S <[email protected]>2020-08-06 02:38:58 +0100
committerGitHub <[email protected]>2020-08-05 21:38:58 -0400
commitad22fb295e9d17c4396f0def74a7476416738ce2 (patch)
tree4b1d3660f821cb31b79f00c9ca28eee3f416049e /discord/ext/commands/help.py
parent[commands] Provide a way to retrieve time left for a cooldown (diff)
downloaddiscord.py-ad22fb295e9d17c4396f0def74a7476416738ce2.tar.xz
discord.py-ad22fb295e9d17c4396f0def74a7476416738ce2.zip
[commands] implement HelpCommand.add/remove_check
Diffstat (limited to 'discord/ext/commands/help.py')
-rw-r--r--discord/ext/commands/help.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/discord/ext/commands/help.py b/discord/ext/commands/help.py
index 21a87396..c7143317 100644
--- a/discord/ext/commands/help.py
+++ b/discord/ext/commands/help.py
@@ -326,6 +326,49 @@ class HelpCommand:
self._command_impl._eject_cog()
self._command_impl = None
+ def add_check(self, func):
+ """
+ Adds a check to the help command.
+
+ .. versionadded:: 1.4
+
+ Parameters
+ ----------
+ func
+ The function that will be used as a check.
+ """
+
+ if self._command_impl is not None:
+ self._command_impl.add_check(func)
+ else:
+ try:
+ self.command_attrs["checks"].append(func)
+ except KeyError:
+ self.command_attrs["checks"] = [func]
+
+ def remove_check(self, func):
+ """
+ Removes a check from the help command.
+
+ This function is idempotent and will not raise an exception if
+ the function is not in the command's checks.
+
+ .. versionadded:: 1.4
+
+ Parameters
+ ----------
+ func
+ The function to remove from the checks.
+ """
+
+ if self._command_impl is not None:
+ self._command_impl.remove_check(func)
+ else:
+ try:
+ self.command_attrs["checks"].remove(func)
+ except (KeyError, ValueError):
+ pass
+
def get_bot_mapping(self):
"""Retrieves the bot mapping passed to :meth:`send_bot_help`."""
bot = self.context.bot