#Slash command autocomplete glitched?

1 messages · Page 1 of 1 (latest)

mystic talon
#

Autocomplete only works when I type something, when I delete what I've typed it's still working, but i gotta type something first or it won't work

azure ivy
#

you want the autocomplete to be shown before the user types something?

buoyant wedge
#

Thats normal for autocomplete

azure ivy
#

yeah that works as intended

#

autocomplete only works when user types

buoyant wedge
#

If your list of options is less than 25 you can use choices instead

mystic talon
#

don't know if i did smth wrong

buoyant wedge
#

Don't know what to tell you, autocomplete function does not fire before you type something, therefore it won't show up. However choices always shows all the options available without typing.

mystic talon
#

i was checking it in another bot

#

it worked sometimes

buoyant wedge
#

Hmm

#

yeah just tested it myself

mystic talon
#

but stopped working after some time too

#

very weird

buoyant wedge
#

show the autocomplete code

azure ivy
#

let me try

buoyant wedge
#

it did for me

mystic talon
#
@diff.autocomplete("name")
    async def namecomplete(
        self, inter: disnake.ApplicationCommandInteraction, string: str
    ):
        string = string.lower()
        canvas_dict = {"e": "earth", "1": "1bit", "m": "moon"}
        guildFolders = [
            filename
            for filename in os.listdir("./factions/")
            if filename.startswith(f"{inter.guild.id}")
        ]
        templates = [
            f'{temp.split("_")[5] if temp.split("_")[5] != ".png" else "0"}% | {temp.split("_")[1]} | {canvas_dict[temp.split("_")[4]]}'
            for temp in os.listdir(f"./factions/{guildFolders[0]}")
            if temp.endswith(".png")
        ]
        for i in range(0, len(templates)):    
          for j in range(i+1, len(templates)):    
            if(float(templates[i].split(" | ")[0].replace('%', '')) < float(templates[j].split(" | ")[0].replace('%', ''))):    
              temp = templates[i];
              templates[i] = templates[j];    
              templates[j] = temp;
        return [lang for lang in templates if string in lang.lower()][0:25]```
#

i'm starting to think discord api is kinda glitched or they updated something

buoyant wedge
#

its the list comprehension at the end

#

it won't return something because string is "" therefore its in none of the templates

#

if len(user_input) == 0: return templates[:25]

#

try adding that before your return statement

azure ivy
#

I have the same problem hmm

mystic talon
azure ivy
#

it doesn't show autocomplete the first time, tho the library receives the interaction

mystic talon
#

yeah it did receive for me too, it just didn't return the list to the client?

azure ivy
#

seems like it

#

let me check it

cinder wolf
#

It's something that has started happening for me as well. And not just autocomplete, disnake.Roles aren't appearing until I start typing

mystic talon
#

(he uses disnake too)

#

not sure if it's a disnake problem or w/ discord api

cinder wolf
#

even optional arguments aren't appearing until I hit "space" after the command

buoyant wedge
mystic talon
#

the list comprehension in the final is not wrong

#

it's always worked like that

#

"" is in all the templates

buoyant wedge
#

print it to sdout

azure ivy
buoyant wedge
#

the list comprehension

azure ivy
#

because disnake does send the callback request

buoyant wedge
#

pretty sure its going to be []

azure ivy
#

ok I think I found the error

#

looks more like a discord client error

mystic talon
azure ivy
#

can you try please type the command with no arguments

azure ivy
#

then go to any server and go back

mystic talon
#

yeah, that kinda fixed for me, happened already

azure ivy
#

it's very weird

mystic talon
#

works perfectly on phone

azure ivy
#

oh so it works on mobile

#

what web/desktop version are you using?

#

Discord does receive the interaction callback

#

so it's definitely a discord problem

mystic talon
azure ivy
#

hmm ptb

#

so ptb is some versions behind canary

#

let me try using stable version

#

same issue

buoyant wedge
#

What version of disnake?