This commit is contained in:
Dragon Fire
2020-12-13 09:54:22 -05:00
parent 87d83051fa
commit bf3b4444fa
3 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -48,12 +48,12 @@ module.exports = class TypingRaceCommand extends Command {
const newScore = Date.now() - now;
const highScoreGet = await this.client.redis.get('typing-test');
const highScore = highScoreGet ? Number.parseInt(highScoreGet, 10) : null;
if (!highScore || highScore < newScore) await this.client.redis.set('typing-test', newScore);
if (!highScore || highScore > newScore) await this.client.redis.set('typing-test', newScore);
this.client.games.delete(msg.channel.id);
if (!winner.size) return msg.say('Oh... No one won.');
return msg.say(stripIndents`
The winner is ${winner.first().author}! (Took ${newScore / 1000} seconds)
${!highScore || highScore < newScore ? `**New High Score!** Old:` : `High Score:`} ${highScore / 1000}
${!highScore || highScore > newScore ? `**New High Score!** Old:` : `High Score:`} ${highScore / 1000}
`);
} catch (err) {
this.client.games.delete(msg.channel.id);
+2 -2
View File
@@ -32,12 +32,12 @@ module.exports = class ReactionTimeCommand extends Command {
const newScore = Date.now() - now;
const highScoreGet = await this.client.redis.get('reaction-time');
const highScore = highScoreGet ? Number.parseInt(highScoreGet, 10) : null;
if (!highScore || highScore < newScore) await this.client.redis.set('reaction-time', newScore);
if (!highScore || highScore > newScore) await this.client.redis.set('reaction-time', newScore);
this.client.games.delete(msg.channel.id);
if (!msgs.size) return msg.say('Failed to answer within 30 seconds.');
return msg.say(stripIndents`
Nice one! (Took ${newScore / 1000} seconds)
${!highScore || highScore < newScore ? `**New High Score!** Old:` : `High Score:`} ${highScore / 1000}
${!highScore || highScore > newScore ? `**New High Score!** Old:` : `High Score:`} ${highScore / 1000}
`);
} catch (err) {
this.client.games.delete(msg.channel.id);
+2 -2
View File
@@ -47,12 +47,12 @@ module.exports = class TypingTestCommand extends Command {
const newScore = Date.now() - now;
const highScoreGet = await this.client.redis.get('typing-test');
const highScore = highScoreGet ? Number.parseInt(highScoreGet, 10) : null;
if (!highScore || highScore < newScore) await this.client.redis.set('typing-test', newScore);
if (!highScore || highScore > newScore) await this.client.redis.set('typing-test', newScore);
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!');
return msg.reply(stripIndents`
Nice job! 10/10! You deserve some cake! (Took ${newScore / 1000} seconds)
${!highScore || highScore < newScore ? `**New High Score!** Old:` : `High Score:`} ${highScore / 1000}
${!highScore || highScore > newScore ? `**New High Score!** Old:` : `High Score:`} ${highScore / 1000}
`);
}
};