Browse Source

[commands] implement HelpCommand.add/remove_check

pull/5212/head
Riley S 5 years ago
committed by GitHub
parent
commit
ad22fb295e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 43
      discord/ext/commands/help.py

43
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

Loading…
Cancel
Save