#Making an Autocomplete 2nd Option Display Differently Based on 1st Option?
27 messages · Page 1 of 1 (latest)
• 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.
Making an Autocomplete 2nd Option Display Differently Based 1st Option?
Making an Autocomplete 2nd Option Display Differently Based on 1st Option?
You can use <AutocompleteInteraction>.options.getString('firstoption') to get the first string option (with the actual option name), for instance
The autocomplete interaction options is missing a couple methods for more advanced types, such as getUser()
You can still .get('name').value on any type of option, which will be the id of a user/role/channel etc
I'm pretty sure the autocomplete guide covers this
Slash Commands: Responding to autocomplete interactions - Handling multiple autocomplete options
read more
I'm essentially trying to have a command like this:
/settings setting:ping value:<this part can change based on what the first setting is selected as>
So I assume if the "setting" option is not also an autocomplete option, I can't get it before the user sends, correct?
So if a user has typed:
/settings setting:ping
I can access what the setting option is before they even press send and then change the value option in relation to that with an autocomplete option? 🤔
yes
You can access the value of other already-filled options in an AutocompleteInteraction
The only part you dont get is full objects for users/roles/channels, but you can still get their ids
Oh neat
I'll try it out, thank you 🙏
In case you got settings that aren’t StringOption but something else you could also make each setting be a subcommand and change the type of option they can enter for each one (and maybe even setChoices instead of autocomplete for those options that only have a fixed set of possible values)
I've thought about doing this but then on the other hand of things, that would result in my just having a lot of subcommands
It would mean having 8 different subcommands and I'm planning to add more 🤷♂️
It would also mean having a subcommand of a subcommand which I'm not sure is possible 🤔
Cause then the command would look like for what I'm doing (as an example):
/settings moderation isEnabled value:true
Or something like that 🤔
there are subcommand groups