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

315
Vistas
Discord.js v13 choices in options - slash commands

in discordjs.guide is how to set choice in option. But there isn't how to get the choice and how to use it with code. I have /animal command with choices (cat, dog, etc..) and when user click on dog, it send dog picture, same with cat. But i don't know where to put the code for image. I tried and this isn't work, writes This interaction failed. How to do it? Thanks (there is text instead of image for testing)

module.exports = {
    data: new SlashCommandBuilder()
        .setName('animal')
        .setDescription('Sends a animal')
        .addStringOption(option =>
            option.setName('animal')
                .setDescription('Select animal for photo')
                .setRequired(true)
                .addChoice('Cat', 'cat')
                .addChoice('Dog', 'dog')),
    async execute(interaction) {
        if (interaction.options.getString() === 'cat') {
            await interaction.reply('cat')
        } else if (interaction.options.getString() === 'dog') {
            await interaction.reply("dog")
        }
    }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Its simple. You normally do interaction.options.getString('animal');

It will give you cat if the user chooses Cat. So basically it is same as how you normally get a option value

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