Skip to content

Commit 8475f90

Browse files
authored
Merge pull request #1575 from NeloBlivion/patch-13
Apply cog_check method to ApplicationCommand invocations
1 parent ec1561e commit 8475f90

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

discord/commands/core.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
from ..role import Role
6464
from ..threads import Thread
6565
from ..user import User
66-
from ..utils import async_all, find, utcnow
66+
from ..utils import async_all, find, utcnow, maybe_coroutine
6767
from .context import ApplicationContext, AutocompleteContext
6868
from .options import Option, OptionChoice
6969

@@ -367,6 +367,14 @@ async def can_run(self, ctx: ApplicationContext) -> bool:
367367
# parent checks should be run first
368368
predicates = self.parent.checks + predicates
369369

370+
cog = self.cog
371+
if cog is not None:
372+
local_check = cog._get_overridden_method(cog.cog_check)
373+
if local_check is not None:
374+
ret = await maybe_coroutine(local_check, ctx)
375+
if not ret:
376+
return False
377+
370378
if not predicates:
371379
# since we have no checks, then we just return True.
372380
return True

0 commit comments

Comments
 (0)