Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

257
Vistas
Create a suggested choice in string options in Discord.JS

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.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar

0

Unfortunately, this isn't possible the way you want to do it. Straight from https://discordjs.guide/interactions/registering-slash-commands.html#option-types/ : Warning about registering slash commands

Of course, there might be other workarounds that I don't know about.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda