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
25 changes: 12 additions & 13 deletions discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,20 +756,19 @@ async def process_application_commands(self, interaction: Interaction, auto_sync
await self.invoke_application_command(ctx)

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

autocomplete_task = self._bot.loop.create_task(callback())
try:
await self._bot.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()
autocomplete_task = self._bot.loop.create_task(callback())
try:
await self._bot.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
Expand Down