Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply cog_check method to ApplicationCommand invocations #1575

Merged
merged 3 commits into from
Aug 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
from ..role import Role
from ..threads import Thread
from ..user import User
from ..utils import async_all, find, utcnow
from ..utils import async_all, find, utcnow, maybe_coroutine
from .context import ApplicationContext, AutocompleteContext
from .options import Option, OptionChoice

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

cog = self.cog
if cog is not None:
local_check = cog._get_overridden_method(cog.cog_check)
if local_check is not None:
ret = await maybe_coroutine(local_check, ctx)
if not ret:
return False

if not predicates:
# since we have no checks, then we just return True.
return True
Expand Down