Split Pokedex Stats and Smogon

This commit is contained in:
Dragon Fire
2021-01-21 16:48:15 -05:00
parent 182cb3c3b3
commit a6ae14c504
3 changed files with 76 additions and 8 deletions
-7
View File
@@ -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} <form>`)} to get stats for another form._
+75
View File
@@ -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!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "126.8.2",
"version": "126.9.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {