mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 13:56:25 +02:00
Memory Command
This commit is contained in:
@@ -224,7 +224,7 @@ in the appropriate channel's topic to use it.
|
|||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
Total: 427
|
Total: 428
|
||||||
|
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
@@ -479,6 +479,7 @@ Total: 427
|
|||||||
* **lottery:** Attempt to win the lottery with 6 numbers.
|
* **lottery:** Attempt to win the lottery with 6 numbers.
|
||||||
* **mad-libs:** Choose words that fill in the blanks to create a crazy story!
|
* **mad-libs:** Choose words that fill in the blanks to create a crazy story!
|
||||||
* **math-quiz:** See how fast you can answer a math problem in a given time limit.
|
* **math-quiz:** See how fast you can answer a math problem in a given time limit.
|
||||||
|
* **memory:** Test your memory.
|
||||||
* **quiz:** Answer a quiz question.
|
* **quiz:** Answer a quiz question.
|
||||||
* **reaction-time:** Test your reaction time.
|
* **reaction-time:** Test your reaction time.
|
||||||
* **rock-paper-scissors:** Play Rock-Paper-Scissors.
|
* **rock-paper-scissors:** Play Rock-Paper-Scissors.
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const { stripIndents } = require('common-tags');
|
||||||
|
const { delay } = require('../../util/Util');
|
||||||
|
const directions = ['up', 'down', 'left', 'right'];
|
||||||
|
|
||||||
|
module.exports = class MemoryCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'memory',
|
||||||
|
group: 'games-sp',
|
||||||
|
memberName: 'memory',
|
||||||
|
description: 'Test your memory.',
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'level',
|
||||||
|
prompt: 'How many directions do you want to have to memorize?',
|
||||||
|
type: 'integer',
|
||||||
|
min: 1,
|
||||||
|
max: 20
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { level }) {
|
||||||
|
const current = this.client.games.get(msg.channel.id);
|
||||||
|
if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`);
|
||||||
|
this.client.games.set(msg.channel.id, { name: this.name });
|
||||||
|
try {
|
||||||
|
const memorize = this.genArray(level);
|
||||||
|
const memorizeDisplay = memorize.map(direction => `\`${direction.toUpperCase()}\``).join(' ');
|
||||||
|
const memorizeMsg = await msg.say(stripIndents`
|
||||||
|
**You have 10 seconds to memorize:**
|
||||||
|
${memorizeDisplay}
|
||||||
|
`);
|
||||||
|
await delay(10000);
|
||||||
|
if (memorizeMsg.deletable) await memorizeMsg.delete();
|
||||||
|
await msg.say('Type what you saw. Don\'t worry about formatting, just the words.');
|
||||||
|
const memorizeType = memorize.join(' ');
|
||||||
|
const msgs = await msg.channel.awaitMessages(res => msg.author.id === res.author.id, {
|
||||||
|
max: 1,
|
||||||
|
time: 30000
|
||||||
|
});
|
||||||
|
this.client.games.delete(msg.channel.id);
|
||||||
|
if (!msgs.size) return msg.say(`Sorry, time is up! It was ${memorizeDisplay}.`);
|
||||||
|
const answer = msgs.first().content.toLowerCase();
|
||||||
|
if (answer !== memorizeType) return msg.say(`Sorry, you typed it wrong. It was ${memorizeDisplay}.`);
|
||||||
|
return msg.say('Nice job! 10/10! You deserve some cake!');
|
||||||
|
} catch (err) {
|
||||||
|
this.client.games.delete(msg.channel.id);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
genArray(level) {
|
||||||
|
const arr = [];
|
||||||
|
for (let i = 0; i < level; i++) arr.push(directions[Math.floor(Math.random() * directions.length)]);
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -29,7 +29,7 @@ module.exports = class ReactionTimeCommand extends Command {
|
|||||||
time: 30000
|
time: 30000
|
||||||
});
|
});
|
||||||
this.client.games.delete(msg.channel.id);
|
this.client.games.delete(msg.channel.id);
|
||||||
if (!msgs.size) return msg.say(`Failed to answer within 30 seconds.`);
|
if (!msgs.size) return msg.say('Failed to answer within 30 seconds.');
|
||||||
return msg.say(`Nice one! (Took ${(Date.now() - now) / 1000} seconds)`);
|
return msg.say(`Nice one! (Took ${(Date.now() - now) / 1000} seconds)`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.client.games.delete(msg.channel.id);
|
this.client.games.delete(msg.channel.id);
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "114.16.8",
|
"version": "114.17.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"gifencoder": "^2.0.1",
|
"gifencoder": "^2.0.1",
|
||||||
"mathjs": "^7.0.0",
|
"mathjs": "^7.0.0",
|
||||||
"moment": "^2.25.3",
|
"moment": "^2.26.0",
|
||||||
"moment-duration-format": "^2.3.2",
|
"moment-duration-format": "^2.3.2",
|
||||||
"moment-timezone": "^0.5.31",
|
"moment-timezone": "^0.5.31",
|
||||||
"node-superfetch": "^0.1.10",
|
"node-superfetch": "^0.1.10",
|
||||||
|
|||||||
Reference in New Issue
Block a user