From 7cde9febcf39afa0c32f79123213f42dfec2073e Mon Sep 17 00:00:00 2001 From: Riley Shaw Date: Sun, 3 Nov 2019 21:45:01 +0000 Subject: [PATCH] [commands] Add Command/Group.add/remove_check --- discord/ext/commands/core.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index 387030161..a37dd641e 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.