mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 06:42:50 +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();
|
const usage = this.client.registry.commands.get('join').usage();
|
||||||
return msg.reply(`I am not in a voice channel. Use ${usage} to fix that!`);
|
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 {
|
try {
|
||||||
const data = await this.client.pokemon.fetch(pokemon.toString());
|
const data = await this.client.pokemon.fetch(pokemon.toString());
|
||||||
const names = data.names.map(name => name.name.toLowerCase());
|
const names = data.names.map(name => name.name.toLowerCase());
|
||||||
@@ -95,6 +98,7 @@ module.exports = class WhosThatPokemonCryCommand extends Command {
|
|||||||
time: 15000
|
time: 15000
|
||||||
});
|
});
|
||||||
connection.play(data.cry);
|
connection.play(data.cry);
|
||||||
|
this.client.games.delete(msg.channel.id);
|
||||||
if (!msgs.size) return msg.reply(`Time! It's **${data.name}**!`, { files: [attachment] });
|
if (!msgs.size) return msg.reply(`Time! It's **${data.name}**!`, { files: [attachment] });
|
||||||
const guess = msgs.first().content.toLowerCase();
|
const guess = msgs.first().content.toLowerCase();
|
||||||
const slug = this.client.pokemon.makeSlug(guess);
|
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] });
|
return msg.reply(`Nice! It's **${data.name}**!`, { files: [attachment] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
this.client.games.delete(msg.channel.id);
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
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 }) {
|
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 {
|
try {
|
||||||
const data = await this.client.pokemon.fetch(pokemon.toString());
|
const data = await this.client.pokemon.fetch(pokemon.toString());
|
||||||
const names = data.names.map(name => name.name.toLowerCase());
|
const names = data.names.map(name => name.name.toLowerCase());
|
||||||
@@ -102,6 +105,7 @@ module.exports = class WhosThatPokemonCommand extends Command {
|
|||||||
connection.play(data.cry);
|
connection.play(data.cry);
|
||||||
await reactIfAble(msg, this.client.user, '🔉');
|
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] });
|
if (!msgs.size) return msg.reply(`Time! It's **${data.name}**!`, { files: [answerAttachment] });
|
||||||
const guess = msgs.first().content.toLowerCase();
|
const guess = msgs.first().content.toLowerCase();
|
||||||
const slug = this.client.pokemon.makeSlug(guess);
|
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] });
|
return msg.reply(`Nice! It's **${data.name}**!`, { files: [answerAttachment] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
this.client.games.delete(msg.channel.id);
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "119.39.3",
|
"version": "119.39.4",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user