Who's That Pokemon Game Limit

This commit is contained in:
Dragon Fire
2020-11-08 09:15:12 -05:00
parent 3d4221916d
commit e08c9f8310
3 changed files with 11 additions and 1 deletions
@@ -83,6 +83,9 @@ module.exports = class WhosThatPokemonCryCommand extends Command {
const usage = this.client.registry.commands.get('join').usage();
return msg.reply(`I am not in a voice channel. Use ${usage} to fix that!`);
}
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 data = await this.client.pokemon.fetch(pokemon.toString());
const names = data.names.map(name => name.name.toLowerCase());
@@ -95,6 +98,7 @@ module.exports = class WhosThatPokemonCryCommand extends Command {
time: 15000
});
connection.play(data.cry);
this.client.games.delete(msg.channel.id);
if (!msgs.size) return msg.reply(`Time! It's **${data.name}**!`, { files: [attachment] });
const guess = msgs.first().content.toLowerCase();
const slug = this.client.pokemon.makeSlug(guess);
@@ -103,6 +107,7 @@ module.exports = class WhosThatPokemonCryCommand extends Command {
}
return msg.reply(`Nice! It's **${data.name}**!`, { files: [attachment] });
} catch (err) {
this.client.games.delete(msg.channel.id);
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
+5
View File
@@ -82,6 +82,9 @@ module.exports = class WhosThatPokemonCommand extends Command {
}
async run(msg, { pokemon }) {
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 data = await this.client.pokemon.fetch(pokemon.toString());
const names = data.names.map(name => name.name.toLowerCase());
@@ -102,6 +105,7 @@ module.exports = class WhosThatPokemonCommand extends Command {
connection.play(data.cry);
await reactIfAble(msg, this.client.user, '🔉');
}
this.client.games.delete(msg.channel.id);
if (!msgs.size) return msg.reply(`Time! It's **${data.name}**!`, { files: [answerAttachment] });
const guess = msgs.first().content.toLowerCase();
const slug = this.client.pokemon.makeSlug(guess);
@@ -110,6 +114,7 @@ module.exports = class WhosThatPokemonCommand extends Command {
}
return msg.reply(`Nice! It's **${data.name}**!`, { files: [answerAttachment] });
} catch (err) {
this.client.games.delete(msg.channel.id);
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "119.39.3",
"version": "119.39.4",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {