Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,14 +743,28 @@ async def process_application_commands(self, interaction: Interaction, auto_sync
return self.dispatch("unknown_application_command", interaction)

if interaction.type is InteractionType.auto_complete:
ctx = await self.get_autocomplete_context(interaction)
ctx.command = command
return await command.invoke_autocomplete_callback(ctx)
return self.dispatch("application_command_auto_complete", interaction, command)

ctx = await self.get_application_context(interaction)
ctx.command = command
await self.invoke_application_command(ctx)

async def on_application_command_auto_complete(self, interaction: Interaction,
command: ApplicationCommand) -> None:
async def callback() -> None:
ctx = await self.get_autocomplete_context(interaction)
ctx.command = command
return await command.invoke_autocomplete_callback(ctx)

autocomplete_task = self.loop.create_task(callback())
try:
await self.wait_for("application_command_auto_complete", check=lambda i, c: c == command, timeout=3)
except asyncio.TimeoutError:
return
else:
if not autocomplete_task.done():
autocomplete_task.cancel()

def slash_command(self, **kwargs):
"""A shortcut decorator that invokes :func:`command` and adds it to
the internal command list via :meth:`add_application_command`.
Expand Down