Files
xiao/commands/response/choose.js
T
Daniel Odendahl 3feaf2a99b Initial Commit
2017-03-02 18:23:16 -05:00

31 lines
1.2 KiB
JavaScript

const commando = require('discord.js-commando');
class ChooseCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'choose',
group: 'response',
memberName: 'choose',
description: 'Chooses between two things. (;choose Cow | Sheep)',
examples: [';choose Cow | Sheep']
});
}
async run(message, args) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
}
console.log("[Command] " + message.content);
if(message.content.includes("|")) {
let choice2 = message.content.split("|").slice(1).join(" ");
let choice1 = " " + message.content.replace(choice2, "").split(" ").slice(1).join(" ");
let coin = [choice1, choice2][Math.floor(Math.random() * 2)];
message.reply("I choose" + coin.replace("|", ""));
} else {
message.reply(":x: Split your two choices with a ' | '!");
}
}
}
module.exports = ChooseCommand;