Making an Autocomplete 2nd Option Display Differently Based on 1st Option?
Is it possible to make a slash command which has a first option which can be some things, and then the second option changes depending on what the thing in the first option is? Any help is greatly appreciated.
10 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
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
Oh not exactly actually
https://discordjs.guide/slash-commands/autocomplete.html#accessing-other-values
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?
yes you can
Provided they have filled it in first
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 🙏
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 🤔