This commit is contained in:
Dragon Fire
2021-01-30 23:09:48 -05:00
parent 8a3f89cd92
commit 3ec12da6e7
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ module.exports = class TypingRaceCommand extends Command {
const highScoreGet = await this.client.redis.get('typing-test');
const highScore = highScoreGet ? Number.parseInt(highScoreGet, 10) : null;
const highScoreUser = await this.client.redis.get('typing-test-user');
const scoreBeat = !highScore || highScore > newScore;
const scoreBeat = winner.size && (!highScore || highScore > newScore);
const user = await fetchHSUserDisplay(this.client, highScoreUser);
if (scoreBeat) {
await this.client.redis.set('typing-test', newScore);
+2 -1
View File
@@ -46,11 +46,12 @@ module.exports = class TypingTestCommand extends Command {
max: 1,
time
});
const win = msgs.size && msgs.first().content === sentence;
const newScore = Date.now() - now;
const highScoreGet = await this.client.redis.get('typing-test');
const highScore = highScoreGet ? Number.parseInt(highScoreGet, 10) : null;
const highScoreUser = await this.client.redis.get('typing-test-user');
const scoreBeat = !highScore || highScore > newScore;
const scoreBeat = win && (!highScore || highScore > newScore);
const user = await fetchHSUserDisplay(this.client, highScoreUser);
if (scoreBeat) {
await this.client.redis.set('typing-test', newScore);