aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-01-26 05:49:24 -0500
committerRapptz <[email protected]>2017-01-26 05:49:24 -0500
commit12c1cd9b149df3ecb6cd7c26f135a43b2ef886d3 (patch)
tree78f198ec3d4bb4342190b84548bfcf236f24785b
parent[commands] Rename __check to __global_check for cogs. (diff)
downloaddiscord.py-12c1cd9b149df3ecb6cd7c26f135a43b2ef886d3.tar.xz
discord.py-12c1cd9b149df3ecb6cd7c26f135a43b2ef886d3.zip
[commands] Add cog local checks via __local_check
-rw-r--r--discord/ext/commands/core.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py
index faa89af9..51a13f94 100644
--- a/discord/ext/commands/core.py
+++ b/discord/ext/commands/core.py
@@ -428,6 +428,16 @@ class Command:
A boolean indicating if the command can be invoked.
"""
+ cog = self.instance
+ if cog is not None:
+ try:
+ local_check = getattr(cog, '_{0.__class__.__name__}__local_check'.format(cog))
+ except AttributeError:
+ pass
+ else:
+ if not local_check(context):
+ return False
+
predicates = self.checks
if not predicates:
# since we have no checks, then we just return True.