DisneyKnowHow11
DisneyKnowHow11

Reputation: 15

Is it possible to say something in the DMs of someone through your discord bot?

Ok, The title could be confusing, but I have nowhere else to go to and I'm very new to JavaScript and Discord.js

My question is whether or not it's possible to make a !say command but with DMs for my discord bot.

bot.on('message', message => {
  if (message.content.startsWith("!say")) {
    if (message.mentions.channels.size == 0) {
      message.reply("please mention a channel first.");
    }
    else {
      let targetChannel = message.mentions.channels.first();

      const args = message.content.split(" ").slice(2);
      let saytext = args.join(" ");
      targetChannel.send(saytext);
      message.delete();
    }
  }
});

This is the code I'm working with. Is there a simple way to make this a DM say command?

Upvotes: 0

Views: 65

Answers (1)

PLASMA chicken
PLASMA chicken

Reputation: 2785

Yes this can be done with:

let targetChannel = message.mentions.users.first();

Upvotes: 1

Related Questions