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

133
Vistas
multiple buttons in one ActionRow

I'm using the discord.js library and node.js to create a Discord bot that can send a DM to a user containing buttons.

I want to send a Discord message with multiple buttons, each with a unique customId and label. My current method is using an list of buttons. I use a for loop adding button objects to the list, and pass it in to the components of the .send method as a list.

x = 5
buttons = []

for (let i = 0; i < x; i++) {
    buttons.push(new MessageActionRow().addComponents(
        new MessageButton()
            .setCustomId(i.toString())
            .setLabel(messageSplit[i])
            .setStyle('PRIMARY')
        )
    )
}

msg.reply({ embeds: [embedRecipient], components: buttons })

This works, but each button is an new ActionRow of its own and thus resulting in the buttons being on different lines. What I mean: image of buttons each on a different line

How can I make it so the same features (like customId and Label) of the buttons retain but they are all on the same line? Making them all in the same one ActionRow should solve this I don't know the code to achieve that.

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

0

To put all the buttons in one single MessageActionRow, you could just declare the row outside the for loop and then inside it, you can just use .addComponents() to add a button to the MessageActionRow. An example is this:

x = 5
const buttons = new MessageActionRow()

for (let i = 0; i < x; i++) {
    buttons.addComponents(
        new MessageButton()
            .setCustomId(i.toString())
            .setLabel(messageSplit[i])
            .setStyle('PRIMARY')
        )
    )
}

msg.reply({ embeds: [embedRecipient], components: [buttons] })
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