#Making an Autocomplete 2nd Option Display Differently Based on 1st Option?

27 messages · Page 1 of 1 (latest)

vast meadow
#

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.

quick surge
#

• 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.

vast meadow
#

Making an Autocomplete 2nd Option Display Differently Based 1st Option?

#

Making an Autocomplete 2nd Option Display Differently Based on 1st Option?

left cliff
#

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()

dreamy oak
#

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

agile knotBOT
#

guide Slash Commands: Responding to autocomplete interactions - Handling multiple autocomplete options
read more

dreamy oak
#

Oh not exactly actually

vast meadow
#

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?

dreamy oak
#

yes you can

#

Provided they have filled it in first

vast meadow
#

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? 🤔

dreamy oak
#

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

vast meadow
#

I'll try it out, thank you 🙏

thorny flume
#

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)

vast meadow
#

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 🤔

proud reef
#

there are subcommand groups