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