Home > Mobile >  How can I get the second mention in a message discord.js v13
How can I get the second mention in a message discord.js v13

Time:06-14

I was making a command, that needs two people to be mentioned, But I do not know how I can do this. I wrote something to check if it works or not, but it didn't work

Code 1:

const user = message.mentions.members.first();
const user2 = message.mentions.members.second() || message.member;

Code 2:

const user = message.mentions.members.first([0]);
const user2 = message.mentions.members.first([1]) || message.member;

They did not work. Can someone say how can I get 2 members from mentioning?

Notes: I am not getting any errors, I am using discord.js v13 and node.js v16

CodePudding user response:

const user = message.mentions.members.first(); // For your first mention
const user1 = message.mentions.members.first(2)[1]; // For your second mention

Same with ID's

const user = message.mentions.members.first() || await message.guild.member.cache.get(args[0]) || await message.guild.members.fetch(args[0]) // First mention
const user = message.mentions.members.first(2)[1] || await message.guild.member.cache.get(args[1]) || await message.guild.members.fetch(args[1]) // First mention

edit:

You can also do 3 mentions just adjust the args[] for ex:

message.mentions.members.first() // First Mention
message.mentions.members.first(2)[1] // Second Mention
message.mentions.members.first(3)[-1] // Third Mention

If the third mention didn't worked. Just adjust it to (3)[2]

  • Related