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
+1 -1
View File
@@ -16,7 +16,7 @@ module.exports = class LotteryCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
let lotteryNumber = ['Winner'][Math.floor(Math.random() * 100)];
const lotteryNumber = ['Winner'][Math.floor(Math.random() * 100)];
if (lotteryNumber !== "Winner") return message.say(`Nope, sorry ${message.author.username}, you lost.`);
return message.say(`Wow ${message.author.username}! You actually won! Great job!`);
}
+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];
}
}
+8 -8
View File
@@ -22,32 +22,32 @@ module.exports = class QuizCommand extends commando.Command {
}
console.log("[Command] " + message.content);
try {
let response = await request
const response = await request
.get('http://jservice.io/api/random')
.query({
count: 1
});
let data = response.body[0];
let answer = data.answer.toLowerCase().split("<i>").join("").split("</i>").join("");
const data = response.body[0];
const answer = data.answer.toLowerCase().split("<i>").join("").split("</i>").join("");
const embed = new Discord.RichEmbed()
.setTitle('You have **fifteen** seconds to answer this question:')
.setDescription(`**Category: ${data.category.title}**\n${data.question}`);
let embedMsg = await message.embed(embed);
const embedMsg = await message.embed(embed);
try {
let collected = await message.channel.awaitMessages(res => res.author.id === message.author.id, {
const collected = await message.channel.awaitMessages(res => res.author.id === message.author.id, {
max: 1,
time: 15000,
errors: ['time']
});
if (collected.first().content.toLowerCase() !== answer) {
let loseMsg = await message.say(`The correct answer is: ${answer}`);
const loseMsg = await message.say(`The correct answer is: ${answer}`);
return [embedMsg, loseMsg];
}
let victoryMsg = await message.say(`The correct answer is: ${answer}`);
const victoryMsg = await message.say(`The correct answer is: ${answer}`);
return [embedMsg, victoryMsg];
}
catch (err) {
let loseMsg = await message.say(`Aw... Too bad, try again next time!\nThe Correct Answer was: ${answer}`);
const loseMsg = await message.say(`Aw... Too bad, try again next time!\nThe Correct Answer was: ${answer}`);
return [embedMsg, loseMsg];
}
}
+1 -1
View File
@@ -30,7 +30,7 @@ module.exports = class RockPaperScissors extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
let rps = args.choice.toLowerCase();
const rps = args.choice.toLowerCase();
let response = ['Paper', 'Rock', 'Scissors'];
response = response[Math.floor(Math.random() * response.length)];
if (rps === "rock") {
+5 -5
View File
@@ -16,11 +16,11 @@ module.exports = class SlotsCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
let slotThing = [':grapes:', ':tangerine:', ':pear:', ':cherries:'];
let slotOne = slotThing[Math.floor(Math.random() * slotThing.length)];
let slotTwo = slotThing[Math.floor(Math.random() * slotThing.length)];
let slotThree = slotThing[Math.floor(Math.random() * slotThing.length)];
let slotFour = slotThing[Math.floor(Math.random() * slotThing.length)];
const slotThing = [':grapes:', ':tangerine:', ':pear:', ':cherries:'];
const slotOne = slotThing[Math.floor(Math.random() * slotThing.length)];
const slotTwo = slotThing[Math.floor(Math.random() * slotThing.length)];
const slotThree = slotThing[Math.floor(Math.random() * slotThing.length)];
const slotFour = slotThing[Math.floor(Math.random() * slotThing.length)];
if (slotOne === slotTwo && slotOne === slotThree && slotOne === slotFour) {
return message.say(`${slotOne}|${slotTwo}|${slotThree}|${slotFour}\nWow! You won! Great job... er... luck!`);
}
+6 -6
View File
@@ -28,7 +28,7 @@ module.exports = class TypingGameCommand 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 randomSentence = ['The quick brown fox jumps over the lazy dog.', 'Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.', 'How razorback-jumping frogs can level six piqued gymnasts!', 'Amazingly few discotheques provide jukeboxes.'];
randomSentence = randomSentence[Math.floor(Math.random() * randomSentence.length)];
let time;
@@ -54,22 +54,22 @@ module.exports = class TypingGameCommand extends commando.Command {
const embed = new Discord.RichEmbed()
.setTitle(`You have **${levelWord}** seconds to type:`)
.setDescription(randomSentence);
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: time,
errors: ['time']
});
if (collected.first().content !== randomSentence) {
let loseMsg = await message.say('Nope, your sentence does not match the original. Try again next time!');
const loseMsg = await message.say('Nope, your sentence does not match the original. Try again next time!');
return [embedMsg, loseMsg];
}
let victoryMsg = await message.say(`Good Job! You won!`);
const victoryMsg = await message.say(`Good Job! You won!`);
return [embedMsg, victoryMsg];
}
catch (err) {
let loseMsg = await message.say('Aw... Too bad, try again next time!');
const loseMsg = await message.say('Aw... Too bad, try again next time!');
return [embedMsg, loseMsg];
}
}