user13189595
user13189595

Reputation:

How can I dm a user only with the ID?

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

Answers (2)

Abhishek Duppati
Abhishek Duppati

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

Tarazed
Tarazed

Reputation: 2655

let user = client.users.cache.get(mention);
user.send('Test DM');

Upvotes: 0

Related Questions