Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda