[commands] implement HelpCommand.add/remove_check
This commit is contained in:
parent
3a9fd00a1a
commit
ad22fb295e
@ -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…
x
Reference in New Issue
Block a user