Reputation: 15
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
Reputation: 2785
Yes this can be done with:
let targetChannel = message.mentions.users.first();
Upvotes: 1