Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

445
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!