Dynamically update command choices without using autocomplete
The title says it all, I don't want to have to use autocomplete as I've found it can be pretty buggy.
I'd like to be able to do something like this:
but currently it just says "No options available" (
gamesArray
is formatted correctly)15 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPPlease ping
If you log
gamesArray
in that commmand file, is it a non-empty array?where do you want me to (outside or in the execute function)
Outside, right above
module.exports = ...
, where it'll be the same value as when you pass it into addChoices()
it's empty, but that's ok, my question is more how can I have the choices update as the array gets longer
without AC
I've gotten it to work (buggily) like this:
randomly it won't recognize the interaction
That's the issue you should be focusing on
Sounds like in your
interactionCreate
listener, you sometimes don't call command.autocomplete(...)
, such as by return
ing before that code is reachedit's unhappy about this bit:
That means you're taking more than 3 seconds between receiving the interaction and your response reaching discord's servers
Do you make any database calls or other intensive function calls in your
interactionCreate
listener?no
and gamesArray is just an array that's saved in the other file, it isn't being fetched each time
That means it's just a hardware issue
Your network is probably too slow since it's likely that your processing speed is fast enough
ah
and you can't defer I guess I'll just have to live with it
or host on better hardware