Reputation: 99
I am trying to make system, that will dm mentioned users and author of the message with random message. But I'm stuck on getting all mentioned users from the message.
const userName = message.author.username;
const userName1 = message.mentions.users.get(1);
const userName2 = message.mentions.users.get(2);
const userName3 = message.mentions.users.get(3);
const userId = message.author.id;
message.channel.send(`Test ${userName}\nTest1 ${userName1}\nTest2 ${userName2}`)
Upvotes: 1
Views: 100
Reputation: 6710
You can call Map on the mentions collection by each user's username and assign it to a usernames
array. Then use each element in that array.
const userName = message.author.username
const usernames = message.mentions.users.map(u => u.username)
const userId = message.author.id
message.channel.send(`Test ${userName}\nTest1 ${usernames[0]}\nTest2 ${usernames[1]}`)
Upvotes: 2