Closed Luc1412 closed 2 years ago
I can reproduce this.
A possible fix would be adding self.callback.__self__
as first parameter if the function is in a class at https://github.com/Pycord-Development/pycord/blob/master/discord/commands/commands.py#L541
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)
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.