Reputation:
if (message.content.includes('!test')) {
var mention = message.mentions.users.first().id;
console.log(mention);
message.mention.send('test')
}
I tried this code and if I type in the chat !test it console logs the ID. Now my question is how I send a DM to the ID. Thanks for helping
Upvotes: 1
Views: 70
Reputation: 663
Try this:
client.fetchUser('id number here').then((user) => {
user.send("Message");
});
This is for existing version v11, for more information related to classes on discord.js, you can find it here at this link
This is to coders who wanna jump into v12 you can start here
Upvotes: 1