mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-22 16:51:59 +00:00
[commands] Add Command/Group.add/remove_check
This commit is contained in:
parent
bf9b9c5879
commit
7cde9febcf
@ -278,6 +278,40 @@ class Command(_BaseCommand):
|
||||
if value.annotation is converters.Greedy:
|
||||
raise TypeError('Unparameterized Greedy[...] is disallowed in signature.')
|
||||
|
||||
def add_check(self, func):
|
||||
"""Adds a check to the command.
|
||||
|
||||
This is the non-decorator interface to :func:`.check`.
|
||||
|
||||
.. versionadded:: 1.3.0
|
||||
|
||||
Parameters
|
||||
-----------
|
||||
func
|
||||
The function that will be used as a check.
|
||||
"""
|
||||
|
||||
self.checks.append(func)
|
||||
|
||||
def remove_check(self, func):
|
||||
"""Removes a check from the command.
|
||||
|
||||
This function is idempotent and will not raise an exception
|
||||
if the function is not in the command's checks.
|
||||
|
||||
.. versionadded:: 1.3.0
|
||||
|
||||
Parameters
|
||||
-----------
|
||||
func
|
||||
The function to remove from the checks.
|
||||
"""
|
||||
|
||||
try:
|
||||
self.checks.remove(func)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
def update(self, **kwargs):
|
||||
"""Updates :class:`Command` instance with updated attribute.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user