Allow case wrong in typing

This commit is contained in:
Dragon Fire
2021-01-31 12:38:17 -05:00
parent 169e116026
commit 4773f651ca
2 changed files with 6 additions and 3 deletions
+4 -1
View File
@@ -39,7 +39,10 @@ module.exports = class TypingRaceCommand extends Command {
files: [{ attachment: img, name: 'typing-race.png' }]
});
const now = Date.now();
const filter = res => [opponent.id, msg.author.id].includes(res.author.id) && res.content === sentence;
const filter = res => {
if (![opponent.id, msg.author.id].includes(res.author.id)) return false;
return res.content.toLowerCase() === sentence;
};
const winner = await msg.channel.awaitMessages(filter, {
max: 1,
time: 30000
+2 -2
View File
@@ -46,7 +46,7 @@ module.exports = class TypingTestCommand extends Command {
max: 1,
time
});
const win = msgs.size && msgs.first().content === sentence;
const win = msgs.size && msgs.first().content.toLowerCase() === sentence;
const newScore = Date.now() - now;
const highScoreGet = await this.client.redis.get('typing-test');
const highScore = highScoreGet ? Number.parseInt(highScoreGet, 10) : null;
@@ -58,7 +58,7 @@ module.exports = class TypingTestCommand extends Command {
await this.client.redis.set('typing-test-user', msg.author.id);
}
if (!msgs.size) return msg.reply('Sorry! You lose!');
if (msgs.first().content !== sentence) return msg.reply('Sorry! You made a typo, so you lose!');
if (msgs.first().content.toLowerCase() !== sentence) return msg.reply('Sorry! You made a typo, so you lose!');
return msg.reply(stripIndents`
Nice job! 10/10! You deserve some cake! (Took ${newScore / 1000} seconds)
${scoreBeat ? `**New High Score!** Old:` : `High Score:`} ${highScore / 1000} (Held by ${user})