High Scores Command

This commit is contained in:
Dragon Fire
2021-01-17 11:14:31 -05:00
parent 6e0b33a922
commit 450925f7f5
3 changed files with 45 additions and 2 deletions
+2 -1
View File
@@ -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.
+42
View File
@@ -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')}
`);
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "126.4.1",
"version": "126.5.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {