mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 14:00:22 +02:00
Who's That Pokemon Game Limit
This commit is contained in:
@@ -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!`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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!`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user