How could I make it send a DM to me?

Hey, using this code:

"const Discord = require(‘discord.js’)

var prefix = process.env.PREFIX

exports.run = async(client, message, args) => {
const reporteduser = message.mentions.members.first();
let reason = args[1]
let time = args[2];
const report = new Discord.RichEmbed()
.setColor(’#7739C4’)
.setTitle(‘New Blacklist!’)
.setDescription(‘Blacklist Info:’)
.addField(‘User blacklisted: ’ + reporteduser)
.addField(‘Reason:’ + reason)
.addField(‘Time:’ + time)
.setFooter(Reported by ${message.author.tag}!)
client.channels.get(‘712656551852376205’).send({ embed: report }).then(async embedMessage => {
message.delete();
message.channel.send(‘:white_check_mark: Blacklist Log has been sent!’)
});
client.channels.get(‘712644464585342986’).send(message.author.tag+ ’ just used the blacklist command!’)

} "

How can I make it so it would DM me the blacklist info?

3 Likes

That shows how to send a message in a channel, I still don’t get how to make it send a DM to me

message.author is a User

The User has a send method.

Meaning that you can use message.author.send("message") to DM someone.

2 Likes

Tysm :heart:

20chars20chars

You’re welcome :slight_smile:

1 Like

But what if someone else runs the command, is there any way I can make it still DM me?

client.users.get("someID").send("someMessage");

‘client’ is how you defined your discord bot (sometimes it’s ‘bot’ or ‘app’)
‘someID’ is the ID of the user you want to send the message to.

How to find ID (click here)

To get your User ID or anyone else’s User ID right click on their name and click “Copy ID” To mention a user in a message right it in with <@id> It should look like this <@357240408373198868> and the numbers are the ID. Don’t think you need to do that in this case

2 Likes

Thanks <3

20chars20chars

1 Like

@okboomer1234321 Does it work OK? Just checking cause I have never used it myself :slight_smile:
Eddie

It does :slight_smile:

20chars20chars

1 Like

Hey @EddiesTech,

Does this still work? Just checking since I am getting lots of errors.

This is the code I use:

  if (message.content.startsWith(prefix + "dm")){
      message.author.send("Message");
  }
1 Like

ty :slight_smile:
20chars

1 Like

It’s also worth mentioning that with the newest Discord.js version, members might not be cached at login, depending on your conigurations.