diff --git a/.env.example b/.env.example index 93f850ee..3877e3ad 100644 --- a/.env.example +++ b/.env.example @@ -31,6 +31,8 @@ FRONT_LINE_EMOJI_ID= SUPPORT_EMOJI_ID= DAMAGE_EMOJI_ID= LOADING_EMOJI_ID= +MEGA_EVOLVE_EMOJI_ID= +MEGA_EVOLVE_EMOJI_NAME= # API Keys, IDs, and Secrets ALPHA_VANTAGE_KEY= diff --git a/commands/search/pokedex.js b/commands/search/pokedex.js index f0815b44..1f7fbf7b 100644 --- a/commands/search/pokedex.js +++ b/commands/search/pokedex.js @@ -2,6 +2,7 @@ const Command = require('../../structures/Command'); const { MessageEmbed } = require('discord.js'); const { stripIndents } = require('common-tags'); const { arrayEquals, firstUpperCase, reactIfAble } = require('../../util/Util'); +const { MEGA_EVOLVE_EMOJI_NAME, MEGA_EVOLVE_EMOJI_ID } = process.env; module.exports = class PokedexCommand extends Command { constructor(client) { @@ -96,6 +97,7 @@ module.exports = class PokedexCommand extends Command { const showParens = variety.name && typesShown.length > 1; return `${variety.types.join('/')}${showParens ? ` (${variety.name})` : ''}`; }).join('\n')) + .addField(`> ${this.megaEvolveEmoji}?`, data.mega ? 'Yes' : 'No', true) .addField('❯ Evolution Chain', data.chain.data.map(pkmn => { if (Array.isArray(pkmn)) { return pkmn.map(pkmn2 => { @@ -146,4 +148,10 @@ module.exports = class PokedexCommand extends Command { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); } } + + get megaEvolveEmoji() { + return MEGA_EVOLVE_EMOJI_ID && MEGA_EVOLVE_EMOJI_NAME + ? `<:${MEGA_EVOLVE_EMOJI_NAME}:${MEGA_EVOLVE_EMOJI_ID}>` + : 'Mega Evolve'; + } }; diff --git a/package.json b/package.json index 03c97a66..26fb0eec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "124.2.0", + "version": "124.2.1", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { diff --git a/structures/pokemon/Pokemon.js b/structures/pokemon/Pokemon.js index 5fb13ea4..aa1b5834 100644 --- a/structures/pokemon/Pokemon.js +++ b/structures/pokemon/Pokemon.js @@ -37,6 +37,7 @@ module.exports = class Pokemon { return { id: variety.pokemon.name, name: name || null, + mega: data.missingno ? false : null, default: variety.is_default, types: data.missingno ? variety.types : [], abilities: data.missingno ? variety.abilities : [] @@ -82,6 +83,11 @@ module.exports = class Pokemon { return 'standard'; } + get mega() { + if (!this.gameDataCached) return null; + return this.varieties.filter(variety => variety.mega); + } + get displayID() { if (this.missingno) return '???'; return this.id.toString().padStart(3, '0'); @@ -140,7 +146,9 @@ module.exports = class Pokemon { for (const variety of this.varieties) { if (variety.id === defaultVariety.id) continue; const { body } = await request.get(`https://pokeapi.co/api/v2/pokemon/${variety.id}`); + const { body: formBody } = await request.get(`https://pokeapi.co/api/v2/pokemon-form/${variety.id}`); variety.types.push(...body.types.map(type => firstUpperCase(type.type.name))); + variety.mega = formBody.is_mega || false; 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);