Formatting

This commit is contained in:
Daniel Odendahl Jr
2017-03-23 01:35:22 +00:00
parent 72718c7c62
commit 40a4af36c4
109 changed files with 2660 additions and 2505 deletions
+18 -17
View File
@@ -3,7 +3,7 @@ const Discord = require('discord.js');
const math = require('mathjs');
module.exports = class MathGameCommand extends commando.Command {
constructor(Client){
constructor(Client) {
super(Client, {
name: 'mathgame',
group: 'random',
@@ -14,8 +14,8 @@ module.exports = class MathGameCommand extends commando.Command {
}
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
}
console.log("[Command] " + message.content);
let [level] = message.content.toLowerCase().split(" ").slice(1);
@@ -24,28 +24,29 @@ module.exports = class MathGameCommand extends commando.Command {
let randomValue;
switch (level) {
case "easy":
randomValue = 10;
break;
randomValue = 10;
break;
case "medium":
randomValue = 50;
break;
randomValue = 50;
break;
case "hard":
randomValue = 100;
break;
case "extreme":
randomValue = 1000;
break;
randomValue = 100;
break;
case "extreme":
randomValue = 1000;
break;
}
let randomValue1 = Math.floor(Math.random() * randomValue) + 1;
let randomValue2 = Math.floor(Math.random() * randomValue) + 1;
let randomExpression = randomValue1 + randomType + randomValue2;
let solved = math.eval(randomExpression);
if(randomValue === undefined) {
if (randomValue === undefined) {
message.channel.send(':x: Error! No difficulty set! (Choose Easy, Medium, Hard, or Extreme)');
} else {
}
else {
const embed = new Discord.RichEmbed()
.setTitle('You have **ten** seconds to answer:')
.setDescription(randomExpression);
.setTitle('You have **ten** seconds to answer:')
.setDescription(randomExpression);
message.channel.sendEmbed(embed).then(() => {
message.channel.awaitMessages(response => response.content === solved.toString() && response.author.id === message.author.id, {
max: 1,
@@ -59,4 +60,4 @@ module.exports = class MathGameCommand extends commando.Command {
});
}
}
};
};