From 622fb39f9851f794ba82cd2ca9e4c368c9735d8e Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Wed, 9 Dec 2020 21:17:02 -0500 Subject: [PATCH] Future-proof pokedex-moveset for Sword/Shield --- assets/json/missingno.json | 1 + commands/search/pokedex-moveset.js | 4 +++- package.json | 2 +- structures/pokemon/Pokemon.js | 5 ++++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/assets/json/missingno.json b/assets/json/missingno.json index 69b5f8d1..8725ee1b 100644 --- a/assets/json/missingno.json +++ b/assets/json/missingno.json @@ -86,6 +86,7 @@ "level": 1 } ], + "moveSetVersion": "red-blue", "chain": [0], "missingno": true, "sprite": "https://cdn.bulbagarden.net/upload/9/98/Missingno_RB.png", diff --git a/commands/search/pokedex-moveset.js b/commands/search/pokedex-moveset.js index d78e0e73..7ea4e6da 100644 --- a/commands/search/pokedex-moveset.js +++ b/commands/search/pokedex-moveset.js @@ -2,7 +2,8 @@ const Command = require('../../structures/Command'); const { MessageEmbed } = require('discord.js'); const versions = { 'red-blue': 'Red and Blue', - 'ultra-sun-ultra-moon': 'Ultra Sun and Ultra Moon' + 'ultra-sun-ultra-moon': 'Ultra Sun and Ultra Moon', + 'sword-shield': 'Sword and Shield' }; module.exports = class PokedexMovesetCommand extends Command { @@ -56,6 +57,7 @@ module.exports = class PokedexMovesetCommand extends Command { const data = await this.client.pokemon.fetch(pokemon); if (!data) return msg.say('Could not find any results.'); if (!data.gameDataCached) await data.fetchGameData(); + if (!data.moveSet.length) return msg.say('This Pokémon\'s moves are not yet documented.'); const embed = new MessageEmbed() .setColor(0xED1C24) .setAuthor(`#${data.displayID} - ${data.name}`, data.boxImageURL, data.serebiiURL) diff --git a/package.json b/package.json index 10d4afd8..8d02d4ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "123.4.0", + "version": "123.4.1", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { diff --git a/structures/pokemon/Pokemon.js b/structures/pokemon/Pokemon.js index 45948eff..ccea61fc 100644 --- a/structures/pokemon/Pokemon.js +++ b/structures/pokemon/Pokemon.js @@ -48,7 +48,7 @@ module.exports = class Pokemon { this.height = data.missingno ? data.height : null; this.weight = data.missingno ? data.weight : null; this.moveSet = data.missingno ? data.moveSet : []; - this.moveSetVersion = data.missingno ? 'red-blue' : 'ultra-sun-ultra-moon'; + this.moveSetVersion = data.missingno ? data.moveSetVersion : null; this.gameDataCached = data.missingno || false; this.missingno = data.missingno || false; this.cry = data.id > store.pokemonCountWithCry @@ -111,6 +111,9 @@ module.exports = class Pokemon { sDef: defaultBody.stats.find(stat => stat.stat.name === 'special-defense').base_stat, spd: defaultBody.stats.find(stat => stat.stat.name === 'speed').base_stat }; + const inSwordShield = defaultBody.moves + .some(move => move.version_group_details.some(mve => mve.version_group.name === 'sword-shield')); + this.moveSetVersion = inSwordShield ? 'sword-shield' : 'ultra-sun-ultra-moon'; for (const move of defaultBody.moves) { const versionGroup = move.version_group_details.find(mve => mve.version_group.name === this.moveSetVersion); if (!versionGroup || !versionGroup.level_learned_at) continue;