For example, if I apply my question to this code from the Discord.JS guide:
const data = new SlashCommandBuilder()
.setName('gif')
.setDescription('Sends a random gif!')
.addStringOption(option =>
option.setName('category')
.setDescription('The gif category')
.setRequired(true)
.addChoice('Funny', 'gif_funny')
.addChoice('Meme', 'gif_meme')
.addChoice('Movie', 'gif_movie'));
This works great, but what if I wanted the choices to be optional, without using a select menu? (i.e., the user can pick "Funny", "Meme", "Movie", or pick their own.)
For my use case, I want to suggest common reasons for mutes:
const { SlashCommandBuilder } = require("@discordjs/builders")
const data = new SlashCommandBuilder()
.setName("mute")
.setDescription("Mute/timeout someone!")
.addUserOption(option =>
option.setName("user")
.setDescription("The user to timeout"))
.setRequired(true)
.addStringOption(option =>
option.setName("duration")
.setDescription("The duration of the timeout")
.setRequired(true)
.addChoice("60 sec.", "1")
.addChoice("5 min.", "2")
.addChoice("10 min.", "3")
.addChoice("1 hr.", "4")
.addChoice("1 day", "5")
.addChoice("1 week", "6")
)
.addStringOption(option =>
option.setName("reason")
.setDescription("The reason for the timeout")
.setRequired(true)
// add optional choices like "Posting memes in #general", etc., but also let them type their own reasons
)
For some reason, the docs have absolutely no information about these new classes. I can't find them.
As someone said on a different platform, autocorrect lets you write your own input anyway. Also, I found the Builders docs: https://discord.js.org/#/docs/builders/stable/general/welcome