mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-11 03:14:35 +02:00
The Power of const
This commit is contained in:
+10
-10
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user