I am trying to make a bot that, whenever someone says something, it sends a message in the channel saying that that person is there and is waiting for someone to join. However, it only prints @ne1 (the role I want it to mention) as plain text. Also, when I have it mention the user, it only writes the user ID instead of actually sending @(username).
const Discord = require('discord.js');
const keepAlive = require('./server');
const client = new Discord.Client();
client.on('message', message => {
if (message.toString().toLowerCase().includes('ne1 here')) {
message.channel.send('@ne1, ' + message.author + ' is online and waiting for you to join!');
}
});
keepAlive();
client.login(process.env.TOKEN);
I am trying to make a bot that, whenever someone says something, it sends a message in the channel saying that that person is there and is waiting for someone to join. However, it only prints @ne1 (the role I want it to mention) as plain text. Also, when I have it mention the user, it only writes the user ID instead of actually sending @(username).
const Discord = require('discord.js');
const keepAlive = require('./server');
const client = new Discord.Client();
client.on('message', message => {
if (message.toString().toLowerCase().includes('ne1 here')) {
message.channel.send('@ne1, ' + message.author + ' is online and waiting for you to join!');
}
});
keepAlive();
client.login(process.env.TOKEN);
What I want is for it to mention the @ne1 role and the person who used the mand to run the bot. It only prints, "@ne1 571713056673890324 is online and waiting for you to join!"
Share Improve this question asked Jul 18, 2020 at 21:48 SimonSimon 771 gold badge2 silver badges12 bronze badges3 Answers
Reset to default 8Discord mentions (role, user, etc.) have a special format as detailed in the documentation here.
So, to mention a user you need to use their user ID <@USER_ID>
/<@!USER_ID>
and for a role it is similarly <@&ROLE_ID>
.
In order to mention a user, you must have their User ID and use the following format:
<@USERID> or <@!USERID>
. For roles do <@&ROLEID>
instead.
Make changes to your message to acmodate it:
message.channel.send(`<@&${ROLEID}> <@${message.author}> is online and waiting for you to join!`);
I guess you are using discord.js v12
If you want the easiest way to mention user you can use
message.channel.send(`@ne1, ${message.author} is online and waiting for you to join!`);
Also I'd use ID of role instead of just @role You can get the ID by using @role and then just using the thing discord outputs Usually something like <@&randomnumbers>