Month names in zodiac-sign, Number.parseInt/isNaN

This commit is contained in:
Daniel Odendahl Jr
2018-02-21 23:58:35 +00:00
parent 30b81c143e
commit 3c90676e30
14 changed files with 62 additions and 30 deletions
+3 -3
View File
@@ -75,7 +75,7 @@ module.exports = class AkinatorCommand extends Command {
id: data.identification.session,
signature: data.identification.signature,
step: 0,
progress: parseInt(data.step_information.progression, 10)
progress: Number.parseInt(data.step_information.progression, 10)
});
return data.step_information;
}
@@ -95,8 +95,8 @@ module.exports = class AkinatorCommand extends Command {
this.sessions.set(channel.id, {
id: session.id,
signature: session.signature,
step: parseInt(data.step, 10),
progress: parseInt(data.progression, 10)
step: Number.parseInt(data.step, 10),
progress: Number.parseInt(data.progression, 10)
});
return data;
}
+3 -3
View File
@@ -73,7 +73,7 @@ module.exports = class ApplesToApplesCommand extends Command {
`);
let chosen = null;
const filter = res => {
const existing = hand[parseInt(res.content, 10) - 1];
const existing = hand[Number.parseInt(res.content, 10) - 1];
if (!existing) return false;
chosen = existing;
return true;
@@ -111,7 +111,7 @@ module.exports = class ApplesToApplesCommand extends Command {
`);
const filter = res => {
if (res.author.id !== czar.user.id) return false;
if (!cards[parseInt(res.content, 10) - 1]) return false;
if (!cards[Number.parseInt(res.content, 10) - 1]) return false;
return true;
};
const chosen = await msg.channel.awaitMessages(filter, {
@@ -122,7 +122,7 @@ module.exports = class ApplesToApplesCommand extends Command {
await msg.say('Hmm... No one wins.');
continue;
}
const player = players.get(cards[parseInt(chosen.first().content, 10) - 1].id);
const player = players.get(cards[Number.parseInt(chosen.first().content, 10) - 1].id);
++player.points;
if (player.points >= maxPts) winner = player.user;
else await msg.say(`Nice one, ${player.user}! You now have **${player.points}** points!`);
+3 -3
View File
@@ -74,7 +74,7 @@ module.exports = class CardsAgainstHumanityCommand extends Command {
`);
const chosen = [];
const filter = res => {
const existing = hand[parseInt(res.content, 10) - 1];
const existing = hand[Number.parseInt(res.content, 10) - 1];
if (!existing) return false;
if (chosen.includes(existing)) return false;
chosen.push(existing);
@@ -112,7 +112,7 @@ module.exports = class CardsAgainstHumanityCommand extends Command {
`);
const filter = res => {
if (res.author.id !== czar.user.id) return false;
if (!cards[parseInt(res.content, 10) - 1]) return false;
if (!cards[Number.parseInt(res.content, 10) - 1]) return false;
return true;
};
const chosen = await msg.channel.awaitMessages(filter, {
@@ -123,7 +123,7 @@ module.exports = class CardsAgainstHumanityCommand extends Command {
await msg.say('Hmm... No one wins.');
continue;
}
const player = players.get(cards[parseInt(chosen.first().content, 10) - 1].id);
const player = players.get(cards[Number.parseInt(chosen.first().content, 10) - 1].id);
++player.points;
if (player.points >= maxPts) winner = player.user;
else await msg.say(`Nice one, ${player.user}! You now have **${player.points}** points!`);
+2 -2
View File
@@ -22,7 +22,7 @@ module.exports = class RouletteCommand extends Command {
prompt: 'What space do you want to bet on?',
type: 'string',
validate: space => {
if (numbers.includes(parseInt(space, 10))) return true;
if (numbers.includes(Number.parseInt(space, 10))) return true;
if (dozens.includes(space)) return true;
if (halves.includes(space)) return true;
if (columns.includes(space.toLowerCase())) return true;
@@ -57,7 +57,7 @@ module.exports = class RouletteCommand extends Command {
}
if (parity.includes(choice)) return parity[result % 2] === choice;
if (columns.includes(choice)) return columns[(result - 1) % 3] === choice;
const number = parseInt(choice, 10);
const number = Number.parseInt(choice, 10);
if (numbers.includes(number)) return result === number;
if (!result) return false;
return false;
+1 -1
View File
@@ -67,7 +67,7 @@ module.exports = class TicTacToeCommand extends Command {
} else if (!sides.includes(choice)) {
await msg.say('I don\'t think that is a valid spot...');
} else {
sides[parseInt(choice, 10)] = sign;
sides[Number.parseInt(choice, 10)] = sign;
taken.push(choice);
if ((sides[0] === sides[1] && sides[0] === sides[2])
|| (sides[0] === sides[3] && sides[0] === sides[6])
+5 -4
View File
@@ -42,7 +42,8 @@ module.exports = class WizardConventionCommand extends Command {
${questions[player.role]} Please type the number.
${valid.map((p, i) => `**${i + 1}.** ${p.user.tag}`).join('\n')}
`);
const decision = await player.user.dmChannel.awaitMessages(res => valid[parseInt(res.content, 10) - 1], {
const filter = res => valid[Number.parseInt(res.content, 10) - 1];
const decision = await player.user.dmChannel.awaitMessages(filter, {
max: 1,
time: 120000
});
@@ -50,7 +51,7 @@ module.exports = class WizardConventionCommand extends Command {
await player.user.send('Sorry, time is up!');
continue;
}
const choice = parseInt(decision.first().content, 10);
const choice = Number.parseInt(decision.first().content, 10);
if (player.role === 'dragon') {
const chosen = players.get(choice);
eaten = chosen.id;
@@ -99,7 +100,7 @@ module.exports = class WizardConventionCommand extends Command {
const filter = res => {
if (!players.exists(p => p.user.id === res.author.id)) return false;
if (voted.includes(res.author.id)) return false;
if (!playersArr[parseInt(res.content, 10) - 1]) return false;
if (!playersArr[Number.parseInt(res.content, 10) - 1]) return false;
voted.push(res.author.id);
return true;
};
@@ -146,7 +147,7 @@ module.exports = class WizardConventionCommand extends Command {
getExpelled(votes, players, playersArr) {
const counts = new Collection();
for (const vote of votes.values()) {
const player = players.get(playersArr[parseInt(vote.content, 10) - 1].id);
const player = players.get(playersArr[Number.parseInt(vote.content, 10) - 1].id);
if (counts.has(player.id)) {
++counts.get(player.id).votes;
} else {