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

108
Vistas
Button issues at discord.js

Well I'm trying to make an avatar config command where it displays the available roles they have to change avatar embed so member can change it by buttons, but the issue is I can't send the buttons based in their roles. I read discord docs but I found nothing. I was able to make a function to replace the roles by string inside an embed and I thought I'd be able to make it with buttons but I think I was wrong.

const Discord = require("discord.js");

function getRoles() {
      let role = message.member.roles.cache
      let text = ""

      if (role.get("staff_role_id")) text += "Staff\n";
      if (role.get("active_member_role_id")) text += "Active Member\n";
      if (role.get("member_role_id")) text += "Member\n";

      roles = `**${text}**`;

      return roles;
    }

const embed = new Discord.MessageEmbed()
.setDescription(`${getRoles(message.member.roles.cache.map(x => x.id).join(`\n`))}`)

let row = new Discord.MessageActionRow()
      .addComponents(
        new Discord.MessageButton()
          .setCustomId(`staff`)
          .setStyle(`SECONDARY`)
          .setLabel(`Staff`)
      )

    let row1 = new Discord.MessageActionRow()
      .addComponents(
        new Discord.MessageButton()
          .setCustomId(`active_member`)
          .setStyle(`SECONDARY`)
          .setLabel(`Active Member`)
      )

    let row2 = new Discord.MessageActionRow()
      .addComponents(
        new Discord.MessageButton()
          .setCustomId(`Member`)
          .setStyle(`SECONDARY`)
          .setLabel(`Membro Stars`)
      )

    function getRoles() {
      let button = ""
          if (message.member.roles.cache.get("staff_role_id")) {
            button += row
          }
          if (message.member.roles.cache.get("active_member_role_id")) {
            button += row1
          }
          if (message.member.roles.cache.get("member_role_id")) {
            button += row2
          }

      buttons = button
      return buttons;
    }

message.channel.send({ embeds: [embed], components: [getRoles] })

Thank you for the help!

about 4 years ago · Santiago Trujillo
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