From 17aaabcd3e5d374bc12090ac24226302041ce0d3 Mon Sep 17 00:00:00 2001 From: Paillat Date: Wed, 28 Jan 2026 12:15:29 +0100 Subject: [PATCH 1/3] :bug: Set autocomplete instance method status on `Option` directly --- discord/commands/core.py | 2 +- discord/commands/options.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/discord/commands/core.py b/discord/commands/core.py index a184a6fcae..499e326a61 100644 --- a/discord/commands/core.py +++ b/discord/commands/core.py @@ -1121,7 +1121,7 @@ async def invoke_autocomplete_callback(self, ctx: AutocompleteContext): ctx.value = op.get("value") ctx.options = values - if option.autocomplete._is_instance_method: + if option._autocomplete_is_instance_method: instance = getattr(option.autocomplete, "__self__", ctx.cog) result = option.autocomplete(instance, ctx) else: diff --git a/discord/commands/options.py b/discord/commands/options.py index 1613630bc0..e62d81d80a 100644 --- a/discord/commands/options.py +++ b/discord/commands/options.py @@ -307,6 +307,7 @@ def __init__( self.default = kwargs.pop("default", None) self._autocomplete: AutocompleteFunction | None = None + self._autocomplete_is_instance_method: bool = False self.autocomplete = kwargs.pop("autocomplete", None) if len(enum_choices) > 25: self.choices: list[OptionChoice] = [] @@ -483,13 +484,13 @@ def autocomplete(self, value: AutocompleteFunction | None) -> None: self._autocomplete = value # this is done here so it does not have to be computed every time the autocomplete is invoked if self._autocomplete is not None: - self._autocomplete._is_instance_method = ( # pyright: ignore [reportFunctionMemberAccess] + self._autocomplete_is_instance_method = ( sum( 1 for param in inspect.signature( self._autocomplete ).parameters.values() - if param.default == param.empty # pyright: ignore[reportAny] + if param.default == param.empty and param.kind not in (param.VAR_POSITIONAL, param.VAR_KEYWORD) ) == 2 From c298a6a415e4c981d756c5a4a400e9aa1aa9aa0e Mon Sep 17 00:00:00 2001 From: Paillat Date: Wed, 28 Jan 2026 12:21:13 +0100 Subject: [PATCH 2/3] :memo: CHANGELO --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8210bcb658..101f23df19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,8 @@ These changes are available on the `master` branch, but have not yet been releas - Fixed an issue where the optional parameters of the `InteractionResponse.send_message` method were not type-hinted as optional. ([#3061](https://github.com/Pycord-Development/pycord/pull/3061)) +- Fixed `AttributeError` when using methods from other classes as `Option.autocomplete`. + ([#3082](https://github.com/Pycord-Development/pycord/pull/3082)) ### Removed From 456adecc51bf55ce70f512a9e0fc76a324f87147 Mon Sep 17 00:00:00 2001 From: Paillat Date: Sat, 31 Jan 2026 16:59:01 +0100 Subject: [PATCH 3/3] Update CHANGELOG.md Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com> Signed-off-by: Paillat --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db55fb53b1..b80f2722f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,7 +48,7 @@ These changes are available on the `master` branch, but have not yet been releas ([#3061](https://github.com/Pycord-Development/pycord/pull/3061)) - Fixed the update of a user's `primary_guild` to now cause an `on_user_update` event to fire. ([#3077](https://github.com/Pycord-Development/pycord/pull/3077)) -- Fixed `AttributeError` when using methods from other classes as `Option.autocomplete`. +- Fixed an error when using methods from other classes regarding option autocompletes. ([#3082](https://github.com/Pycord-Development/pycord/pull/3082)) ### Removed