diff --git a/commands/pokedex/pokedex-stats.js b/commands/pokedex/pokedex-stats.js index 68b5c757..853e1e17 100644 --- a/commands/pokedex/pokedex-stats.js +++ b/commands/pokedex/pokedex-stats.js @@ -54,7 +54,11 @@ module.exports = class PokedexCommand 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(); - const variety = data.varieties.find(vrity => form ? vrity.name.toLowerCase() === form : vrity.default); + const variety = data.varieties.find(vrity => { + if (!form) return vrity.default; + if (!vrity.name && form === 'normal') return true; + return vrity.name.toLowerCase() === form; + }); if (!variety) { const varieties = data.varieties.map(vrity => vrity.name || 'Normal'); return msg.say(`Invalid form. The forms available for this Pokémon are: ${list(varieties, 'and')}`); @@ -69,6 +73,7 @@ module.exports = class PokedexCommand extends Command { spd: Math.round((variety.stats.spd / 255) * 10) * 2, total: Math.round((statTotal / 720) * 10) * 2 }; + const displayForms = data.varieties.filter(vrity => vrity.statsDiffer); const embed = new MessageEmbed() .setColor(0xED1C24) .setAuthor(`#${data.displayID} - ${data.name}`, data.boxImageURL, data.serebiiURL) @@ -85,8 +90,9 @@ module.exports = class PokedexCommand extends Command { `) .addField('❯ Abilities', variety.abilities.join('/')) .addField('❯ Other Forms', stripIndents` - Use ${this.usage(`${data.id}
`)} to get stats for another form. - Forms Available: ${data.varieties.map(vrity => vrity.name || 'Normal').join(', ')} + _Use ${this.usage(`${data.id} `)} to get stats for another form._ + + **Forms Available:** ${displayForms.map(vrity => `\`${vrity.name || 'Normal'}\``).join(', ')} `); return msg.embed(embed); } catch (err) { diff --git a/commands/pokedex/pokedex.js b/commands/pokedex/pokedex.js index 40b04f35..569c1315 100644 --- a/commands/pokedex/pokedex.js +++ b/commands/pokedex/pokedex.js @@ -126,7 +126,6 @@ module.exports = class PokedexCommand extends Command { } return msg.embed(embed); } catch (err) { - throw 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 f3011b29..3b277669 100644 --- a/structures/pokemon/Pokemon.js +++ b/structures/pokemon/Pokemon.js @@ -39,6 +39,7 @@ module.exports = class Pokemon { name: name || null, mega: data.missingno ? false : null, stats: data.missingno ? variety.stats : {}, + statsDiffer: data.missingno ? true : null, default: variety.is_default, types: data.missingno ? variety.types : [], abilities: data.missingno ? variety.abilities : [] @@ -139,6 +140,7 @@ 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 }; + defaultVariety.statsDiffer = true; 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'; @@ -165,7 +167,14 @@ module.exports = class Pokemon { sAtk: body.stats.find(stat => stat.stat.name === 'special-attack').base_stat, sDef: body.stats.find(stat => stat.stat.name === 'special-defense').base_stat, spd: body.stats.find(stat => stat.stat.name === 'speed').base_stat - } + }; + const baseStats = defaultVariety.stats; + variety.statsDiffer = baseStats.hp !== variety.stats.hp + || baseStats.atk !== variety.stats.atk + || baseStats.def !== variety.stats.def + || baseStats.sAtk !== variety.stats.sAtk + || baseStats.sDef !== variety.stats.sDef + || baseStats.spd !== variety.stats.spd; for (const ability of body.abilities) { const { body: abilityBody } = await request.get(ability.ability.url); variety.abilities.push(abilityBody.names.find(name => name.language.name === 'en').name);