Multi Select in command parameter

Hello, i have a general question. Is it possible to enable multi-selection, similar to stringSelectMenus, as a command parameter? Let me explain some more: Example items
new SlashCommandBuilder()
.setName("gifs")
.setDescription("Select your favourite gifs")
.addStringOption(option =>
option
.setName("gifs")
.setDescription("favorite gifs")
.setChoices(
...choices,
)
.setRequired(true),
)

const choices =
[
{ name: 'Funny', value: 'gif_funny' },
{ name: 'Meme', value: 'gif_meme' },
{ name: 'Movie', value: 'gif_movie' },
]
new SlashCommandBuilder()
.setName("gifs")
.setDescription("Select your favourite gifs")
.addStringOption(option =>
option
.setName("gifs")
.setDescription("favorite gifs")
.setChoices(
...choices,
)
.setRequired(true),
)

const choices =
[
{ name: 'Funny', value: 'gif_funny' },
{ name: 'Meme', value: 'gif_meme' },
{ name: 'Movie', value: 'gif_movie' },
]
I want to create a command that allows you to select multiple choices as parameters for /gifs. For example something like this /gifs Funny Meme Its not possible right? The only solution that comes to mind is to add as many 'not required' options as needed to allow the selection of a certain number of favorite gifs like this:
new SlashCommandBuilder()
.setName("gifs")
.setDescription("Select your favourite gifs")
.addStringOption(option =>
option
.setName("gif")
.setDescription("favorite gifs")
.setChoices(
...choices,
)
.setRequired(true),
)
.addStringOption(option =>
option
.setName("gif1")
.setDescription("another favorite gif")
.setChoices(
...choices,
)
.setRequired(false), //default to false, just wanted to make it explicit
)
new SlashCommandBuilder()
.setName("gifs")
.setDescription("Select your favourite gifs")
.addStringOption(option =>
option
.setName("gif")
.setDescription("favorite gifs")
.setChoices(
...choices,
)
.setRequired(true),
)
.addStringOption(option =>
option
.setName("gif1")
.setDescription("another favorite gif")
.setChoices(
...choices,
)
.setRequired(false), //default to false, just wanted to make it explicit
)
Is there any other way? Thanks in advance!
18 Replies
d.js toolkit
d.js toolkit14mo ago
- 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 OP
treble/luna
treble/luna14mo ago
No
Sim3Xx
Sim3XxOP14mo ago
okay 😄 Thanks
treble/luna
treble/luna14mo ago
you can indeed add more options, or just use a selectmenu
Sim3Xx
Sim3XxOP14mo ago
But if want the user to select only unique choices i need to use autocomplete right?
treble/luna
treble/luna14mo ago
autocomplete are just dynamic choices if you have preset choices, the user has to pick from them with autocomplete they can also enter a custom text
Sim3Xx
Sim3XxOP14mo ago
Ah okay, so i cant really limit the list of available choices so that the user can only pick a gif once? So something like this doesnt happen /gifs gif:Meme gif1: Meme?
treble/luna
treble/luna14mo ago
for that you can use autocomplete yes
Sim3Xx
Sim3XxOP14mo ago
alright perfect. Thank you so much for helping 🙂
treble/luna
treble/luna14mo ago
you're welcome!
Sim3Xx
Sim3XxOP14mo ago
I really appreciate it. Okay one last question :d Do i get the selected choice in the autocomplete interaction?
NotDemonix
NotDemonix14mo ago
you get the value
treble/luna
treble/luna14mo ago
i havent played arounf with autocomplete too much, interaction.options.getFocused() should do that
NotDemonix
NotDemonix14mo ago
i do .getString() which gives me the value, i think its more useful than the name
treble/luna
treble/luna14mo ago
yeah thats also a good way indeed
Sim3Xx
Sim3XxOP14mo ago
Alright thanks ❤️ Have a good day
NotDemonix
NotDemonix14mo ago
you too!
Sim3Xx
Sim3XxOP14mo ago
Thank you too 🙂
Want results from more Discord servers?
Add your server