diff --git a/commands/games-sp/whos-that-pokemon.js b/commands/games-sp/whos-that-pokemon.js index 4dca65ce..a6d6acf9 100644 --- a/commands/games-sp/whos-that-pokemon.js +++ b/commands/games-sp/whos-that-pokemon.js @@ -60,7 +60,9 @@ module.exports = class WhosThatPokemonCommand extends Command { time: 15000 }); if (!msgs.size) return msg.reply(`Sorry, time is up! It was ${data.name}.`); - if (!names.includes(msgs.first().content.toLowerCase())) return msg.reply(`Nope, sorry, it's ${data.name}.`); + const guess = msgs.first().content.toLowerCase(); + const slug = this.client.pokemon.makeSlug(guess); + if (!names.includes(guess) && data.slug !== slug) return msg.reply(`Nope, sorry, it's ${data.name}.`); return msg.reply('Nice job! 10/10! You deserve some cake!'); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/structures/pokemon/Pokemon.js b/structures/pokemon/Pokemon.js index bda796b4..d9a87812 100644 --- a/structures/pokemon/Pokemon.js +++ b/structures/pokemon/Pokemon.js @@ -34,7 +34,7 @@ module.exports = class Pokemon { } get slug() { - return encodeURIComponent(this.name.toLowerCase().replace(/ /g, '-').replace(/[^a-zA-Z0-9-]/g, '')); + return this.store.makeSlug(this.name); } get spriteImageURL() { diff --git a/structures/pokemon/PokemonStore.js b/structures/pokemon/PokemonStore.js index 699d7b09..263f960c 100644 --- a/structures/pokemon/PokemonStore.js +++ b/structures/pokemon/PokemonStore.js @@ -5,7 +5,7 @@ const missingno = require('../../assets/json/missingno'); module.exports = class PokemonStore extends Collection { async fetch(query) { - query = encodeURIComponent(query.toLowerCase().replace(/ /g, '-').replace(/[^a-zA-Z0-9-]/g, '')); + query = this.makeSlug(query); if (!query) return null; const num = Number.parseInt(query, 10); if (this.has(num)) return this.get(num); @@ -26,4 +26,8 @@ module.exports = class PokemonStore extends Collection { throw err; } } + + makeSlug(query) { + return encodeURIComponent(query.toLowerCase().replace(/ /g, '-').replace(/[^a-zA-Z0-9-]/g, '')); + } };