From 153a07fdaf7316381bb9069a7900228891a3feec Mon Sep 17 00:00:00 2001 From: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Date: Thu, 10 Mar 2022 22:20:06 +0300 Subject: [PATCH] Revert "Revert "Run parent checks in `can_run` (#1027)" (#1158)" This reverts commit 4af2e6dc3cd81885c29a239307e49d1d7cc0b50d. --- discord/commands/core.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/discord/commands/core.py b/discord/commands/core.py index e48db22904..fcaf3bc13d 100644 --- a/discord/commands/core.py +++ b/discord/commands/core.py @@ -317,6 +317,10 @@ async def can_run(self, ctx: ApplicationContext) -> bool: raise CheckFailure(f"The global check functions for command {self.name} failed.") predicates = self.checks + if self.parent is not None: + # parent checks should be ran first + predicates = self.parent.checks + predicates + if not predicates: # since we have no checks, then we just return True. return True @@ -898,7 +902,7 @@ def __init__( self.subcommands: List[Union[SlashCommand, SlashCommandGroup]] = self.__initial_commands__ self.guild_ids = guild_ids self.parent = parent - self.checks = [] + self.checks = kwargs.get("checks", []) self._before_invoke = None self._after_invoke = None