How to get the user id, username, nick when mentioned by another user

I tried m.mentions.members.first() but to no avail it didn't work as expected due to the mentions property being undefined despite mentioning someone. Any help would be appreciated! Here's the brief code:
module.exports = {

callback: async (m) => {

let user = m.member.nickname;
let mentionedUser = m.mentions.members.first();

if ( mentionedUser === undefined) {
m.channel.send("You need to mention someone!")
return;
}
m.channel.send(`${user} mentioned ${m.mentions.members.first()}`) //test
},
};
module.exports = {

callback: async (m) => {

let user = m.member.nickname;
let mentionedUser = m.mentions.members.first();

if ( mentionedUser === undefined) {
m.channel.send("You need to mention someone!")
return;
}
m.channel.send(`${user} mentioned ${m.mentions.members.first()}`) //test
},
};
15 Replies
d.js toolkit
d.js toolkit9mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
probablyraging
probablyraging9mo ago
Where is the message coming from, DM or channel? message.members don't exist in a DM channel message
Koi
KoiOP9mo ago
Oh I forgot to note that, it is indeed from a channel
chewie
chewie9mo ago
can you log m and show the output
Koi
KoiOP9mo ago
this?
No description
chewie
chewie9mo ago
no, log m first thing in the function console.log(m)
Koi
KoiOP9mo ago
I sent the message with a mention still null?
No description
chewie
chewie9mo ago
can you please show the whole thing
Koi
KoiOP9mo ago
alrighty holdon
Koi
KoiOP9mo ago
chewie
chewie9mo ago
thats not a djs message object then m.message is
Koi
KoiOP9mo ago
ooo i see so i'll have to do m.message first ?
chewie
chewie9mo ago
yes
Koi
KoiOP9mo ago
Omg it worked! Thank you
chewie
chewie9mo ago
:reallyFckingCuteCatThumbsUp:
Want results from more Discord servers?
Add your server