-
-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autocomplete callbacks can't be methods of classes #392
Comments
I can reproduce this. |
A possible fix would be adding |
I'm not sure if this is related but whenever I try to use an autocomplete I get this error TypeError: Autocomplete callback must be a coroutine. Here is my code @staticmethod
async def num_picker(ctx: ApplicationContext) -> Iterable[int]:
"""Return a list of random integers."""
return [random.randint(1, 100) for _ in range(25)]
@slash_command(guild_ids=settings.dev_guild_ids)
async def num(
self, ctx: ApplicationContext,
extension: Option(int, autocomplete=num_picker)
-> None:
await ctx.respond(extension) |
You used a staticmethod, which should run like a normal function. Also we're thinking about making autocomplete accept sync functions. |
This has been fixed, let me know if there are any issues. |
Summary
If the automcomplete
Reproduction Steps
Minimal Reproducible Code
Expected Results
The class reference should be filled like in command callbacks.
Actual Results
Exception in event:
on_interaction
Intents
guilds, members, emojis, webhooks, voice_states, guild_messages, guild_reactions, dm_messages, dm_reactions
System Information
Checklist
Additional Context
As an alternative, you can put the callback outside of a cog. This would cause that you can't access the bot, cog, or any other useful reference.
The text was updated successfully, but these errors were encountered: