Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

173
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\]});
7 months 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.

7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs