Send DM Command

This commit is contained in:
Daniel Odendahl Jr
2017-04-04 01:52:04 +00:00
parent 88e1534a56
commit b6a67eeac0
+45
View File
@@ -0,0 +1,45 @@
const commando = require('discord.js-commando');
module.exports = class SendDMCommand extends commando.Command {
constructor(Client) {
super(Client, {
name: 'senddm',
aliases: [
'dm',
'recontact'
],
group: 'util',
memberName: 'senddm',
description: "Sends a DM to a user ID.",
examples: [";senddm 278305350804045834 This is a DM."],
args: [{
key: 'userid',
prompt: 'What is the User ID of the user you wish to contact?',
type: 'string',
validate: userID => {
if (userID.length === 18) {
return true;
}
return "Invalid ID.";
}
}, {
key: 'content',
prompt: 'What would you like the content of the message to be?',
type: 'string'
}]
});
}
hasPermission(msg) {
return this.client.isOwner(msg.author);
}
run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
const userID = args.userid;
const content = args.content;
return this.client.users.get(userID).send(content).catch(err => message.say(':x: Error! Something went wrong!'));
}
};