Autocomplete failing to load choices
Here is my code:
I have a pre-loaded games cache that is roughly 1600 games in an array. The command returns the games if I just hit enter and skip the autocomplete, however I want to list the matches just for a better UX. Atm it just does this whats shown in the pic. BUT hitting enter and just running it shows the games
20 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.Is it logging the "handle Autocomplete called"?
no
Also I don't see you getting the focused option's value anywhere, I hope you're not mistaking "interaction.options.getString()" for that
I'm not gonna lie the one thing that confuses me a lot is autocomplete
Then it's an issue with calling the function, show me how you call the function
The guide has a step by step process to help you with autocomplete
let me take another look at the guide
Alright, you can always ask for help here
Oh I know, I'm just super tired and might take a break until tomorrow and reply here haha. But, if anything updates before then I'll post progress
Yeah I'm kinda stumped right now
Even using the example with fixed options that has the guide command, it doesn't load anything
If it doesnt log the string at the top of the function then the function isn't being called, show me how you call the function
I'm assuming you mean this?
Ah there we go
You have
if(!interaction.isChatInputCommand()) return
at the top
It'll instantly not run the code if any interaction recieved is not a slash command
And you dont call the handle Autocomplete function
Is this function attached to the command
object? Like command.execute()
?I thought autocomplete was a slash command, no? I also don't see what you mean about the isChatInputCommand
or, wait thats basically the same
yeah
Like uh...
Autocomplete interactions come from a slash command yes but slash commands are chatinputcommand interactions whereas autocomplete options send autocomplete interactions
2 different interactions
Ah, okay
So I need to add an event handler for that
Hm, although... whats the site people use to paste code
https://codeshare.io/YLVM6b
that'll do
Then just for testing, do this
alright, will try
Not event handler but rather an interaction handler, all you need to do is check the type of interaction recieved then move accordingly
As seen in the lil snippet I shown above
It can be done in one listener but if you'd like you can create another just for autocomplete interactions
After you're done, try it and if it doesn't work, show me the code
you sensei