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

448
Visualizações
Ping a role in an auto message from my custom Discord bot

I'm facing an issue concerning my Discord bot. I made an automatic answer that pings the user when he gets a role. Everything works fine, the user gets pinged and the embed appears as planed.

I would like to add a role ping to this message. The problem with the following code is that the role won't get pinged (just the role, the username and the embed work perfectly). It just shows the ID of the role exactly like in the code.

Could someone tell me if there's an error in this line:

channel.send({content :`**${oldMember.user} something is written here** <@&11111111111111>, something is written here too`, embeds :\[embed\]});

(11111111111 = role ID)

I expect my bot to ping the role every time this message is sent. I tried the mentioned code line and this one as well, but this shows "@deleted-role":

channel.send({content :`**${oldMember.user} something is written here** <@&${1111111111111}, something is written here too`, embeds :\[embed\]});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

After some researching, I found a workable code:

const role = message.guild.roles.cache.filter(role => role.id === "11111111111111");

channel.send({content :`**${oldMember.user} something is written here** ${role}, something is written here too`, embeds :\[embed\]});

https://discord.js.org/#/docs/discord.js/stable/class/RoleManager the Discord.js documentations are really helpful as a resource.

about 4 years ago · Juan Pablo Isaza Relatório
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