diff --git a/README.md b/README.md index bceb2fcb..7bbec609 100644 --- a/README.md +++ b/README.md @@ -261,7 +261,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 576 +Total: 577 ### Utility: @@ -271,6 +271,7 @@ Total: 576 * **credit:** Responds with a command's credits list. * **donate:** Responds with the bot's donation links. * **help:** Displays a list of available commands, or detailed information for a specific command. +* **high-scores:** Responds with the high scores the bot has saved. * **info:** Responds with detailed bot information. * **invite:** Responds with the bot's invite links. * **join:** Joins your voice channel. diff --git a/commands/util-public/high-scores.js b/commands/util-public/high-scores.js new file mode 100644 index 00000000..c500ecc7 --- /dev/null +++ b/commands/util-public/high-scores.js @@ -0,0 +1,42 @@ +const Command = require('../../structures/Command'); +const { stripIndents } = require('common-tags'); +const moment = require('moment'); +require('moment-duration-format'); +const minesweeperSizes = [3, 4, 5, 6, 7, 8, 9, 10]; + +module.exports = class HighScoresCommand extends Command { + constructor(client) { + super(client, { + name: 'high-scores', + aliases: ['high-score', 'hs', 'h-score', 'high-s'], + group: 'util-public', + memberName: 'high-scores', + description: 'Responds with the high scores the bot has saved.', + guarded: true + }); + } + + async run(msg) { + const typingRaceGet = await this.client.redis.get('typing-test'); + const typingRace = typingRaceGet ? Number.parseInt(typingRaceGet, 10) : null; + const anagramsGet = await this.client.redis.get('anagramica'); + const anagrams = anagramsGet ? Number.parseInt(anagramsGet, 10) : null; + const minesweeperScores = {}; + for (const size of minesweeperSizes) { + const minesweeperGet = await this.client.redis.get(`minesweeper-${size}`); + const minesweeper = minesweeperGet ? Number.parseInt(minesweeperGet, 10) : null; + minesweeperScores[size] = moment.duration(minesweeper).format('mm:ss'); + } + const reactionTimeGet = await this.client.redis.get('reaction-time'); + const reactionTime = reactionTimeGet ? Number.parseInt(reactionTimeGet, 10) : null; + return msg.say(stripIndents` + __**Single-Score Games:**__ + \`typing-race\`/\`typing-test\`: ${typingRace}s + \`anagramica\`: ${anagrams} + \`reaction-time\`: ${reactionTime}s + + __**Minesweeper:**__ + ${Object.entries(minesweeperScores).map(([size, score]) => `\`${size}x${size}\`: ${score}`).join('\n')} + `); + } +}; diff --git a/package.json b/package.json index d5dee8e6..22bae330 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "126.4.1", + "version": "126.5.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {