mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Allow case wrong in typing
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user