From e08c9f8310b6d028fdc36bf1926dd9385d3d6cc4 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 8 Nov 2020 09:15:12 -0500 Subject: [PATCH] Who's That Pokemon Game Limit --- commands/games-sp/whos-that-pokemon-cry.js | 5 +++++ commands/games-sp/whos-that-pokemon.js | 5 +++++ package.json | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/commands/games-sp/whos-that-pokemon-cry.js b/commands/games-sp/whos-that-pokemon-cry.js index e3a9bc56..229f885d 100644 --- a/commands/games-sp/whos-that-pokemon-cry.js +++ b/commands/games-sp/whos-that-pokemon-cry.js @@ -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!`); } } diff --git a/commands/games-sp/whos-that-pokemon.js b/commands/games-sp/whos-that-pokemon.js index c9347585..1e7a464a 100644 --- a/commands/games-sp/whos-that-pokemon.js +++ b/commands/games-sp/whos-that-pokemon.js @@ -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!`); } } diff --git a/package.json b/package.json index 281380ec..bdd635d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.39.3", + "version": "119.39.4", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {