The Power of const

This commit is contained in:
Daniel Odendahl Jr
2017-04-03 22:31:19 +00:00
parent 4f0f1b4ad2
commit 76907549df
87 changed files with 525 additions and 558 deletions
+10 -10
View File
@@ -29,7 +29,7 @@ module.exports = class MathGameCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
}
console.log(`[Command] ${message.content}`);
let level = args.difficulty.toLowerCase();
const level = args.difficulty.toLowerCase();
let randomType = ['+', '-', '*'];
randomType = randomType[Math.floor(Math.random() * randomType.length)];
let randomValue;
@@ -47,29 +47,29 @@ module.exports = class MathGameCommand extends commando.Command {
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);
const randomValue1 = Math.floor(Math.random() * randomValue) + 1;
const randomValue2 = Math.floor(Math.random() * randomValue) + 1;
const randomExpression = randomValue1 + randomType + randomValue2;
const solved = math.eval(randomExpression);
const embed = new Discord.RichEmbed()
.setTitle('You have **ten** seconds to answer:')
.setDescription(randomExpression);
let embedMsg = await message.embed(embed);
const embedMsg = await message.embed(embed);
try {
let collected = await message.channel.awaitMessages(response => response.author.id === message.author.id, {
const collected = await message.channel.awaitMessages(response => response.author.id === message.author.id, {
max: 1,
time: 10000,
errors: ['time']
});
if (collected.first().content !== solved.toString()) {
let loseMsg = await message.say(`Aw... Too bad, try again next time!\nThe correct answer is: ${solved}`);
const loseMsg = await message.say(`Aw... Too bad, try again next time!\nThe correct answer is: ${solved}`);
return [embedMsg, loseMsg];
}
let victoryMsg = await message.say(`Good Job! You won! ${solved} is the correct answer!`);
const victoryMsg = await message.say(`Good Job! You won! ${solved} is the correct answer!`);
return [embedMsg, victoryMsg];
}
catch (err) {
let loseMsg = await message.say(`Aw... Too bad, try again next time!\nThe correct answer is: ${solved}`);
const loseMsg = await message.say(`Aw... Too bad, try again next time!\nThe correct answer is: ${solved}`);
return [embedMsg, loseMsg];
}
}