Finish removing "Oh no, an error occurred"

This commit is contained in:
Dragon Fire
2024-03-30 11:59:42 -04:00
parent f6b59c2d46
commit a135cac031
119 changed files with 3418 additions and 4116 deletions
+19 -27
View File
@@ -12,6 +12,7 @@ module.exports = class MemoryCommand extends Command {
group: 'games-sp',
memberName: 'memory',
description: 'Test your memory.',
game: true,
args: [
{
key: 'level',
@@ -24,33 +25,24 @@ module.exports = class MemoryCommand extends Command {
}
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(word => `\`${word.toUpperCase()}\``).join(' ');
const memorizeMsg = await msg.say(stripIndents`
**You have 10 seconds to memorize:**
${memorizeDisplay}
`);
await delay(10000);
await memorizeMsg.edit('Type what you saw. Don\'t worry about formatting, just the words.');
const memorizeType = memorize.join(' ');
const msgs = await msg.channel.awaitMessages({
filter: 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;
}
const memorize = this.genArray(level);
const memorizeDisplay = memorize.map(word => `\`${word.toUpperCase()}\``).join(' ');
const memorizeMsg = await msg.say(stripIndents`
**You have 10 seconds to memorize:**
${memorizeDisplay}
`);
await delay(10000);
await memorizeMsg.edit('Type what you saw. Don\'t worry about formatting, just the words.');
const memorizeType = memorize.join(' ');
const msgs = await msg.channel.awaitMessages({
filter: res => msg.author.id === res.author.id,
max: 1,
time: 30000
});
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!');
}
genArray(level) {