diff --git a/commands/pokedex/pokedex-stats.js b/commands/pokedex/pokedex-stats.js index 27417709..fb51a766 100644 --- a/commands/pokedex/pokedex-stats.js +++ b/commands/pokedex/pokedex-stats.js @@ -65,8 +65,6 @@ 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 fetchGames = genGames.slice(data.generation, data.missingno ? 2 : genGames.length); - if (!data.missingno) await data.fetchSmogonTiers(...fetchGames); const displayForms = data.varieties.filter(vrity => vrity.statsDiffer); const variety = displayForms.find(vrity => { if (!form || form === 'normal') return vrity.default; @@ -102,11 +100,6 @@ module.exports = class PokedexCommand extends Command { \`Total: [${'█'.repeat(repeat.total)}${' '.repeat(20 - repeat.total)}]\` **${statTotal}** `) .addField('❯ Abilities', variety.abilities.join('/')) - .addField('❯ Smogon Tiers', - fetchGames.map(game => { - const smogonData = data.smogonTiers[game]; - return `[${smogonData.join('/')}](${data.smogonURL(game)}) (${games[game]})`; - }).join('\n')) .addField('❯ Other Forms', stripIndents` _Use ${this.usage(`${data.id}
`)} to get stats for another form._ diff --git a/commands/pokedex/smogon.js b/commands/pokedex/smogon.js new file mode 100644 index 00000000..576fc4f6 --- /dev/null +++ b/commands/pokedex/smogon.js @@ -0,0 +1,75 @@ +const Command = require('../../structures/Command'); +const { MessageEmbed } = require('discord.js'); +const { stripIndents } = require('common-tags'); +const genGames = [null, 'rb', 'gs', 'rs', 'dp', 'bw', 'xy', 'sm', 'ss']; +const games = { + rb: 'Red/Blue', + gs: 'Gold/Silver', + rs: 'Ruby/Sapphire', + dp: 'Diamond/Pearl', + bw: 'Black/White', + xy: 'X/Y', + sm: 'Sun/Moon', + ss: 'Sword/Shield' +}; + +module.exports = class SmogonCommand extends Command { + constructor(client) { + super(client, { + name: 'smogon', + aliases: ['pokemon-smogon', 'smogon-tier', 'pokémon-smogon', 'pkmn-smogon'], + group: 'pokedex', + memberName: 'smogon', + description: 'Responds with the Smogon tiers for a Pokémon.', + clientPermissions: ['EMBED_LINKS'], + credit: [ + { + name: 'Pokémon', + url: 'https://www.pokemon.com/us/', + reason: 'Images, Original Game' + }, + { + name: 'PokéAPI', + url: 'https://pokeapi.co/', + reason: 'API' + }, + { + name: 'Serebii.net', + url: 'https://www.serebii.net/index2.shtml', + reason: 'Images' + }, + { + name: 'Smogon', + url: 'https://www.smogon.com/', + reason: 'Tier Data' + } + ], + args: [ + { + key: 'pokemon', + prompt: 'What Pokémon would you like to get information on?', + type: 'string' + } + ] + }); + } + + async run(msg, { pokemon }) { + try { + const data = await this.client.pokemon.fetch(pokemon); + if (!data) return msg.say('Could not find any results.'); + const fetchGames = genGames.slice(data.generation, data.missingno ? 2 : genGames.length); + if (!data.missingno) await data.fetchSmogonTiers(...fetchGames); + const embed = new MessageEmbed() + .setColor(0xED1C24) + .setAuthor(`#${data.displayID} - ${data.name}`, data.formBoxImageURL(variety.id), data.serebiiURL) + .setThumbnail(data.formSpriteImageURL(variety.id)); + for (const game of fetchGames) { + embed.addField(`❯ ${games[game]}`, `[${data.smogonTiers[game].join('/')}](${data.smogonURL(game)})`, true); + } + return msg.embed(embed); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index 1f0c5c08..ef293157 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "126.8.2", + "version": "126.9.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {