From b1fb5ed3d7712c98abf1b218869f09699b7abe89 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Wed, 30 Mar 2022 19:46:27 -0400 Subject: [PATCH] Fix autocomplete not working with renamed parameters Fix #7810 --- discord/app_commands/commands.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/discord/app_commands/commands.py b/discord/app_commands/commands.py index 3a1b4467a..c49ea851e 100644 --- a/discord/app_commands/commands.py +++ b/discord/app_commands/commands.py @@ -564,12 +564,19 @@ class Command(Generic[GroupT, P, T]): raise CommandInvokeError(self, e) from e async def _invoke_autocomplete(self, interaction: Interaction, name: str, namespace: Namespace): + # The namespace contains the Discord provided names so this will be fine + # even if the name is renamed value = namespace.__dict__[name] try: param = self._params[name] except KeyError: - raise CommandSignatureMismatch(self) from None + # Slow case, it might be a rename + params = {param.display_name: param for param in self._params.values()} + try: + param = params[name] + except KeyError: + raise CommandSignatureMismatch(self) from None if param.autocomplete is None: raise CommandSignatureMismatch(self)