Skip to content

Commit 2a319bd

Browse files
Fix #392
1 parent 16e7aff commit 2a319bd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

discord/commands/commands.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,16 @@ async def invoke_autocomplete_callback(self, ctx: AutocompleteContext):
540540
ctx.focused = option
541541
ctx.value = op.get("value")
542542
ctx.options = values
543-
if asyncio.iscoroutinefunction(option.autocomplete):
544-
result = await option.autocomplete(ctx)
543+
544+
if len(inspect.signature(option.autocomplete).parameters) == 2:
545+
result = option.autocomplete(getattr(option.autocomplete, "__self__", ctx.cog), ctx)
545546
else:
546547
result = option.autocomplete(ctx)
547548

549+
if asyncio.iscoroutinefunction(option.autocomplete):
550+
result = await result
551+
552+
548553
choices = [
549554
o if isinstance(o, OptionChoice) else OptionChoice(o)
550555
for o in result

0 commit comments

Comments
 (0)