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

113
Vistas
Change button style if clicked in discord.js

I need help about changing the button style in Discord.JS. interaction.component.setStyle("DANGER") works, but for multi-buttons inside an Action Row doesn't work. I tried <row>.components, it shows an array of MessageButton. I can also <row>.components[0].setStyle("DANGER") but it can't do the clicked one. Can you please help? Thank you!

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

0

Using interaction.message.components[0] would return the first MessageActionRow.

Take a look at the image that I've linked below to see the numbers that I've been talking about.

In order to edit button 5, you would have to get the 2nd button of the 2nd row. This would be interaction.components[1].components[1]. You can then edit stuff like the style, label, etc. by running the usual .setLabel("Something") function.

Don't forget to reply to the interaction. In your case you would have to update the original interaction-message.

A possible way to insert this would be:

const { Client } = require("discord.js")
const client = new Client(/*Your intents*/)

//Your code to create the buttons, etc.

client.on("interactionCreate", interaction=>{
if(interaction.isButton()){
  if(interaction.customId=="your custom button id"){
    //Remember to start counting with 0. 0 in the code equals 1 in real life... 
    interaction.message.components[1].interaction[1].setStyle("DANGER")
    
    interaction.update({
      components: interaction.components
    })
  }
}
})
client.login("your token")

Buttons with the numbers I talked 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