From 5e98626d41e6e39f82b9fbdc7a0723311fe5751b Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 30 Apr 2022 19:53:27 -0400 Subject: [PATCH] Run parent command checks before calling autocomplete callback Fixes #7969 --- discord/app_commands/commands.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/discord/app_commands/commands.py b/discord/app_commands/commands.py index 818603fe1..b167462ac 100644 --- a/discord/app_commands/commands.py +++ b/discord/app_commands/commands.py @@ -675,6 +675,19 @@ class Command(Generic[GroupT, P, T]): if param.autocomplete is None: raise CommandSignatureMismatch(self) + try: + if not await self._check_can_run(interaction): + if not interaction.response.is_done(): + await interaction.response.autocomplete([]) + return + except AppCommandError: + # Exceptions can't reasonably be handled by the developer at this point + # The autocomplete can either fail or return an empty list of options + # Both of these are more or less the same UX to the user. + if not interaction.response.is_done(): + await interaction.response.autocomplete([]) + return + if param.autocomplete.requires_binding: binding = param.autocomplete.binding or self.binding if binding is not None: