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 toolkit10mo 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
zevnda
zevnda10mo ago
Where is the message coming from, DM or channel? message.members don't exist in a DM channel message
Koi
KoiOP10mo ago
Oh I forgot to note that, it is indeed from a channel
chewie
chewie10mo ago
can you log m and show the output
Koi
KoiOP10mo ago
this?
No description
chewie
chewie10mo ago
no, log m first thing in the function console.log(m)
Koi
KoiOP10mo ago
I sent the message with a mention still null?
No description
chewie
chewie10mo ago
can you please show the whole thing
Koi
KoiOP10mo ago
alrighty holdon
Koi
KoiOP10mo ago
chewie
chewie10mo ago
thats not a djs message object then m.message is
Koi
KoiOP10mo ago
ooo i see so i'll have to do m.message first ?
chewie
chewie10mo ago
yes
Koi
KoiOP10mo ago
Omg it worked! Thank you
chewie
chewie10mo ago
:reallyFckingCuteCatThumbsUp:
Want results from more Discord servers?
Add your server