aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiley Shaw <[email protected]>2019-11-03 21:45:01 +0000
committerRapptz <[email protected]>2019-11-15 04:29:52 -0500
commit7cde9febcf39afa0c32f79123213f42dfec2073e (patch)
tree28b4cbbb8beeb99c8bf1a2f8cd1425687d696f60
parentAdjust BASE urls to have no trailing slash (consistency) (diff)
downloaddiscord.py-7cde9febcf39afa0c32f79123213f42dfec2073e.tar.xz
discord.py-7cde9febcf39afa0c32f79123213f42dfec2073e.zip
[commands] Add Command/Group.add/remove_check
-rw-r--r--discord/ext/commands/core.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py
index 38703016..a37dd641 100644
--- a/discord/ext/commands/core.py
+++ b/discord/ext/commands/core.py
@@ -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.