I'm trying to build a bot which mentions people on discord. I already have the usernames of people, and I've been trying to mention users with this :
function discordsend(usern)
{
string = "$add-money"+usern+"1";
const channel = client.channels.cache.get('channelid');
channel.send(string)
console.log(channel);
}
However, it just sends the message plainly to the channel without actually mentioning the user. Is there any way I could mention a user just using their user id ? (Username with Discriminator)
I've also heard I can mention users if I have their IDs, but I only have their User IDs. If there is a way to obtain IDs from UserIDs, please let me know !
FYI, UserID is in the form user#discriminator
Discord uses a special syntax to embed mentions in a message. For user mentions, it is the user's ID with <@ at the start and > at the end, like this:
<@12345678912345678>
If they have a nickname, there will also be a ! after the @.
If I read your question correctly, you wanted to mention a member using their ID only, to use their ID you need to cache.get:
const member = message.guild.members.cache.get(args[0])
if you're familiar with args functions then you can use it too with channels and roles
If you wanted to ping them in bot's messages. you can use ${member}
for example:
message.channel.send(`${member}`)