Skip to content

autocomplete issues. #1190

@MaxOrtGit

Description

@MaxOrtGit

Summary

autocomplete double pings when option is first loaded and if you switch to a different autocomplete option before the first sends to discord it will give you the result of the first autocomplete instead of the second.

Reproduction Steps

Double ping bug:
The autocomplete function always gets called twice even if there is no delay.
This also happens when you return to the option even if there is already text in it.

Wrong autocomplete function:
The first autocomplete has to take a bit to get results or take a while to ping the server. In the example I used a wait of 1 second but this bug can occur even if the wait is as low as 0.1 sec.
It is hard to get the timing right on computer but on mobile it pings with the autocomplete function after the user clicks an autocomplete result making this bug super common.

autocomplete.bug.mp4

Minimal Reproducible Code

bot = commands.Bot()
gid = [gidid]

async def test_autocomplete(ctx: discord.AutocompleteContext):
  print(f"test 1, value = {ctx.value}")
  await asyncio.sleep(1)
  return ["test 1 autocomplete", "output"]
async def test_two_autocomplete(ctx: discord.AutocompleteContext):
  print(f"test 2, value = {ctx.value}")
  return ["test 2 autocomplete", "output"]
  
@bot.slash_command(name = "test", description = "test." , guild_ids = gid)
async def test(ctx, test: Option(str, "test", autocomplete=test_autocomplete), test_two: Option(str, "test", autocomplete=test_two_autocomplete)):
  await ctx.respond(f"test {test}, test 2 {test_two}")

bot.run(token)

Expected Results

The autocomplete function gets called once initially and when you switch the the second option it should use the second autocomplete function.

Actual Results

The first autocomplete function gets called twice initially and when the user switches to the second option it shows the autocomplete result from the first option.

Intents

all

System Information

  • Python v3.10.3-final
  • py-cord v2.0.0-beta
    • py-cord pkg_resources: v2.0.0b5
  • aiohttp v3.8.1
  • system info: Windows 10 10.0.19042

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    unconfirmed bugA bug report that needs triaging

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions