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

148
Vistas
Discord Button failed Pop up on command

I am trying to make a Menu for my Discord server and I've got the slash command working, but with I go to pull the menu I get: Main menu as a return in discord when executing the slash command.

I used the following code to get as far as I have:

    //Remember to run " node deploy-commands.js " to register your commands!

const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageActionRow, MessageButton } = require('discord.js');


module.exports = {
    data: new SlashCommandBuilder()
        .setName('menu')
        .setDescription('Brings up the Main Menu'),
    async execute(interaction, client) {
        const row = new MessageActionRow()
                        .addComponents(
                                new MessageButton()
                                        .setCustomId('dice-bag')
                                        .setLabel('danger')
                                        .setStyle("DANGER"),
                                
                                new MessageButton()
                                        .setCustomId('spells')
                                        .setLabel('primary')
                                        .setStyle("PRIMARY"),
                                        
                                new MessageButton()
                                        .setCustomId('inventory')
                                        .setLabel('Success')
                                        .setStyle("SUCCESS"),
                        );
                        await interaction.reply({content: 'Main menu,', components: [row]})
    },
};

I have a feeling I need to embed the message somehow but am not 100% sure how. I'm pretty sure that I need to likely add something the:

await interaction.reply({content: 'Main menu,', components: [row]})

I'm pretty sure the components: [row]}) is wrong but I'm not sure what to put in its place. anytime I try to fix it I get errors about MessageActionRow action row needing NEW.

Thank you for any help!

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

0

Note! This is assuming you are using Discord.js v13.2.0.


According to the documentation, <MessageActionRow>.addComponents(...) expects an Array of MessageActionRowComponentResolveables. This look something like this:

<MessageActionRow>.addComponents([
new MessageButton().setValue("option1").setStyle("PRIMARY"),
new MessageButton().setValue("option2").setStyle("DANGER")
]);

The important thing to note here is the usage of braces ([]). In JavaScript, braces indicate an Array. In your code, you are missing the braces.

// DON'T do this!
<MessageActionRow>.addComponents(new MessageButton, new MessageButton);

// DO this!
<MessageActionRow>.addComponents([ new MessageButton, new MessageButton ]);

With that, your code isn't too different. All you have to do is add the braces.

<MessageActionRow>.addComponents([
new MessageButton()
.setCustomId('dice-bag')
.setLabel('danger')
.setStyle("DANGER"),

new MessageButton()
.setCustomId('spells')
.setLabel('primary')
.setStyle("PRIMARY"),
                                        
new MessageButton()
.setCustomId('inventory')
.setLabel('Success')
.setStyle("SUCCESS")
]);
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