Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!