mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-16 15:57:54 +02:00
Trainer Card Command
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"styles": {
|
||||||
|
"default": 3
|
||||||
|
},
|
||||||
|
"characters": {
|
||||||
|
"ash": 13,
|
||||||
|
"red": 922,
|
||||||
|
"ethan": 900,
|
||||||
|
"lyra": 901,
|
||||||
|
"brendan": 241,
|
||||||
|
"may": 255,
|
||||||
|
"lucas": 747,
|
||||||
|
"dawn": 856
|
||||||
|
},
|
||||||
|
"badges": {
|
||||||
|
"kanto": [2, 3, 4, 5, 6, 7, 8, 9],
|
||||||
|
"johto": [10, 11, 12, 13, 14, 15, 16, 17],
|
||||||
|
"hoenn": [18, 19, 20, 21, 22, 23, 24, 25],
|
||||||
|
"sinnoh": [26, 27, 28, 29, 30, 31, 32, 33],
|
||||||
|
"unova": [34, 35, 36, 37, 38, 39, 40, 41],
|
||||||
|
"kalos": [44, 45, 46, 47, 48, 49, 50, 51]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const request = require('node-superfetch');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const { stripIndents } = require('common-tags');
|
||||||
|
const { list } = require('../../util/Util');
|
||||||
|
const { styles, characters, badges } = require('../../assets/json/trainer-card');
|
||||||
|
|
||||||
|
module.exports = class TrainerCardCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'trainer-card',
|
||||||
|
aliases: [
|
||||||
|
'pkmn-trainer',
|
||||||
|
'pokemon-trainer',
|
||||||
|
'pokémon-trainer',
|
||||||
|
'pkmn-trainer-card',
|
||||||
|
'pokemon-trainer-card',
|
||||||
|
'pokémon-trainer-card',
|
||||||
|
'pkmn-tc',
|
||||||
|
'pokemon-tc',
|
||||||
|
'pokémon-tc',
|
||||||
|
'ptc'
|
||||||
|
],
|
||||||
|
group: 'edit-image',
|
||||||
|
memberName: 'trainer-card',
|
||||||
|
description: 'Creates a trainer card for a Pokémon trainer.',
|
||||||
|
details: stripIndents`
|
||||||
|
**Styles:** ${Object.keys(styles).join(', ')}
|
||||||
|
**Characters:** ${Object.keys(characters).join(', ')}
|
||||||
|
**Badges:** ${Object.keys(badges).join(', ')}
|
||||||
|
`,
|
||||||
|
credit: [
|
||||||
|
{
|
||||||
|
name: 'Pokémon',
|
||||||
|
url: 'https://www.pokemon.com/us/',
|
||||||
|
reason: 'Images, Original Game'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'PokéAPI',
|
||||||
|
url: 'https://pokeapi.co/',
|
||||||
|
reason: 'API'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Pokécharms',
|
||||||
|
url: 'https://pokecharms.com/',
|
||||||
|
reason: 'Trainer Card API',
|
||||||
|
reasonURL: 'https://pokecharms.com/trainer-card-maker/'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'style',
|
||||||
|
prompt: `What style do you want to use? Either ${list(Object.keys(styles), 'or')}.`,
|
||||||
|
type: 'string',
|
||||||
|
oneOf: Object.keys(styles),
|
||||||
|
parse: style => styles[style.toLowerCase()]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'name',
|
||||||
|
prompt: 'What name do you want to use?',
|
||||||
|
type: 'string',
|
||||||
|
max: 12
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'character',
|
||||||
|
prompt: `What character do you want to use? Either ${list(Object.keys(characters, 'or'))}.`,
|
||||||
|
type: 'string',
|
||||||
|
oneOf: Object.keys(characters),
|
||||||
|
parse: character => characters[character.toLowerCase()]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'badgeChoice',
|
||||||
|
label: 'badges',
|
||||||
|
prompt: `What badges do you want to use? Either ${list(Object.keys(badges), 'or')}.`,
|
||||||
|
type: 'string',
|
||||||
|
oneOf: Object.keys(badges),
|
||||||
|
parse: choice => badges[choice.toLowerCase()]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'pokemon',
|
||||||
|
label: 'Pokémon',
|
||||||
|
prompt: 'What Pokémon do you want to use? Please enter up to 6 (in seperate messages).',
|
||||||
|
type: 'pokemon',
|
||||||
|
infinite: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { style, name, character, badgeChoice, pokemon }) {
|
||||||
|
try {
|
||||||
|
const pokemonUsed = [];
|
||||||
|
for (const pkmn of pokemon) {
|
||||||
|
const id = await this.fetchPokemonID(pkmn.id);
|
||||||
|
pokemonUsed.push(id);
|
||||||
|
}
|
||||||
|
const card = await this.createCard(style, name, character, badgeChoice, pokemonUsed);
|
||||||
|
return msg.say({ files: [{ attachment: card, name: 'trainer-card.png' }] });
|
||||||
|
} catch (err) {
|
||||||
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async createCard(style, name, character, badgeChoice, pokemon) {
|
||||||
|
const { body } = await request
|
||||||
|
.post('https://pokecharms.com/index.php?trainer-card-maker/render')
|
||||||
|
.attach('trainername', name)
|
||||||
|
.attach('background', style)
|
||||||
|
.attach('character', character)
|
||||||
|
.attach('badges', 8)
|
||||||
|
.attach('badgesUsed', badgeChoice)
|
||||||
|
.attach('pokemon', pokemon.length)
|
||||||
|
.attach('pokemonUsed', pokemon)
|
||||||
|
.attach('_xfResponseType', 'json');
|
||||||
|
return Buffer.from(body.trainerCard, 'base64');
|
||||||
|
}
|
||||||
|
|
||||||
|
async fetchPokemonID(pokemon) {
|
||||||
|
const { body } = await request
|
||||||
|
.post('https://pokecharms.com/trainer-card-maker/pokemon-panels')
|
||||||
|
.attach('number', pokemon.id)
|
||||||
|
.attach('_xfResponseType', 'json');
|
||||||
|
const $ = cheerio.load(body.templateHtml);
|
||||||
|
return $('li[class="Panel"]').first().attr('data-id');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -49,7 +49,7 @@ module.exports = class PokedexCryCommand extends Command {
|
|||||||
{
|
{
|
||||||
key: 'pokemon',
|
key: 'pokemon',
|
||||||
prompt: 'What Pokémon would you like to play the cry of?',
|
prompt: 'What Pokémon would you like to play the cry of?',
|
||||||
type: 'string'
|
type: 'pokemon'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -62,9 +62,7 @@ module.exports = class PokedexCryCommand extends Command {
|
|||||||
return msg.reply(`I am not in a voice channel. Use ${usage} to fix that!`);
|
return msg.reply(`I am not in a voice channel. Use ${usage} to fix that!`);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const data = await this.client.pokemon.fetch(pokemon);
|
connection.play(pokemon.cry);
|
||||||
if (!data) return msg.say('Could not find any results.');
|
|
||||||
connection.play(data.cry);
|
|
||||||
await reactIfAble(msg, this.client.user, '🔉');
|
await reactIfAble(msg, this.client.user, '🔉');
|
||||||
return null;
|
return null;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ module.exports = class PokedexImageCommand extends Command {
|
|||||||
{
|
{
|
||||||
key: 'pokemon',
|
key: 'pokemon',
|
||||||
prompt: 'What Pokémon would you like to get the image of?',
|
prompt: 'What Pokémon would you like to get the image of?',
|
||||||
type: 'string'
|
type: 'pokemon'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -48,9 +48,7 @@ module.exports = class PokedexImageCommand extends Command {
|
|||||||
|
|
||||||
async run(msg, { pokemon }) {
|
async run(msg, { pokemon }) {
|
||||||
try {
|
try {
|
||||||
const data = await this.client.pokemon.fetch(pokemon);
|
return msg.say(`#${pokemon.displayID} - ${pokemon.name}`, { files: [pokemon.spriteImageURL] });
|
||||||
if (!data) return msg.say('Could not find any results.');
|
|
||||||
return msg.say(`#${data.displayID} - ${data.name}`, { files: [data.spriteImageURL] });
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ module.exports = class PokedexLocationCommand extends Command {
|
|||||||
{
|
{
|
||||||
key: 'pokemon',
|
key: 'pokemon',
|
||||||
prompt: 'What Pokémon would you like to get information on?',
|
prompt: 'What Pokémon would you like to get information on?',
|
||||||
type: 'string'
|
type: 'pokemon'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -50,20 +50,18 @@ module.exports = class PokedexLocationCommand extends Command {
|
|||||||
|
|
||||||
async run(msg, { pokemon }) {
|
async run(msg, { pokemon }) {
|
||||||
try {
|
try {
|
||||||
const data = await this.client.pokemon.fetch(pokemon);
|
if (!pokemon.gameDataCached) await pokemon.fetchGameData();
|
||||||
if (!data) return msg.say('Could not find any results.');
|
if (!pokemon.encounters) await pokemon.fetchEncounters();
|
||||||
if (!data.gameDataCached) await data.fetchGameData();
|
const desc = pokemon.encounters.length
|
||||||
if (!data.encounters) await data.fetchEncounters();
|
? pokemon.encounters
|
||||||
const desc = data.encounters.length
|
|
||||||
? data.encounters
|
|
||||||
.map(location => `${location.name} (${location.versions.map(v => versions[v]).join('/')})`)
|
.map(location => `${location.name} (${location.versions.map(v => versions[v]).join('/')})`)
|
||||||
.join('\n')
|
.join('\n')
|
||||||
: 'Location Unknown';
|
: 'Location Unknown';
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0xED1C24)
|
.setColor(0xED1C24)
|
||||||
.setAuthor(`#${data.displayID} - ${data.name}`, data.boxImageURL, data.serebiiURL)
|
.setAuthor(`#${pokemon.displayID} - ${pokemon.name}`, pokemon.boxImageURL, pokemon.serebiiURL)
|
||||||
.setDescription(desc)
|
.setDescription(desc)
|
||||||
.setThumbnail(data.spriteImageURL);
|
.setThumbnail(pokemon.spriteImageURL);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ module.exports = class PokedexMovesetCommand extends Command {
|
|||||||
{
|
{
|
||||||
key: 'pokemon',
|
key: 'pokemon',
|
||||||
prompt: 'What Pokémon would you like to get information on?',
|
prompt: 'What Pokémon would you like to get information on?',
|
||||||
type: 'string'
|
type: 'pokemon'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -54,16 +54,14 @@ module.exports = class PokedexMovesetCommand extends Command {
|
|||||||
|
|
||||||
async run(msg, { pokemon }) {
|
async run(msg, { pokemon }) {
|
||||||
try {
|
try {
|
||||||
const data = await this.client.pokemon.fetch(pokemon);
|
if (!pokemon.gameDataCached) await pokemon.fetchGameData();
|
||||||
if (!data) return msg.say('Could not find any results.');
|
if (!pokemon.moveSet.length) return msg.say('This Pokémon\'s moves are not yet documented.');
|
||||||
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()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0xED1C24)
|
.setColor(0xED1C24)
|
||||||
.setAuthor(`#${data.displayID} - ${data.name}`, data.boxImageURL, data.serebiiURL)
|
.setAuthor(`#${pokemon.displayID} - ${pokemon.name}`, pokemon.boxImageURL, pokemon.serebiiURL)
|
||||||
.setDescription(data.moveSet.map(move => `**Level ${move.level}:** ${move.move.name}`).join('\n'))
|
.setDescription(pokemon.moveSet.map(move => `**Level ${move.level}:** ${move.move.name}`).join('\n'))
|
||||||
.setThumbnail(data.spriteImageURL)
|
.setThumbnail(pokemon.spriteImageURL)
|
||||||
.setFooter(`Moveset data taken from ${versions[data.moveSetVersion]}.`);
|
.setFooter(`Moveset data taken from ${versions[pokemon.moveSetVersion]}.`);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ module.exports = class PokedexCommand extends Command {
|
|||||||
{
|
{
|
||||||
key: 'pokemon',
|
key: 'pokemon',
|
||||||
prompt: 'What Pokémon would you like to get information on?',
|
prompt: 'What Pokémon would you like to get information on?',
|
||||||
type: 'string'
|
type: 'pokemon'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'form',
|
key: 'form',
|
||||||
@@ -51,10 +51,8 @@ module.exports = class PokedexCommand extends Command {
|
|||||||
|
|
||||||
async run(msg, { pokemon, form }) {
|
async run(msg, { pokemon, form }) {
|
||||||
try {
|
try {
|
||||||
const data = await this.client.pokemon.fetch(pokemon);
|
if (!pokemon.gameDataCached) await pokemon.fetchGameData();
|
||||||
if (!data) return msg.say('Could not find any results.');
|
const displayForms = pokemon.varieties.filter(vrity => vrity.statsDiffer);
|
||||||
if (!data.gameDataCached) await data.fetchGameData();
|
|
||||||
const displayForms = data.varieties.filter(vrity => vrity.statsDiffer);
|
|
||||||
const variety = displayForms.find(vrity => {
|
const variety = displayForms.find(vrity => {
|
||||||
if (!form || form === 'normal') return vrity.default;
|
if (!form || form === 'normal') return vrity.default;
|
||||||
if (!vrity.name) return false;
|
if (!vrity.name) return false;
|
||||||
@@ -64,7 +62,7 @@ module.exports = class PokedexCommand extends Command {
|
|||||||
const varieties = displayForms.map(vrity => vrity.name || 'Normal');
|
const varieties = displayForms.map(vrity => vrity.name || 'Normal');
|
||||||
return msg.say(`Invalid form. The forms available for this Pokémon are: ${list(varieties, 'and')}`);
|
return msg.say(`Invalid form. The forms available for this Pokémon are: ${list(varieties, 'and')}`);
|
||||||
}
|
}
|
||||||
const statTotal = data.baseStatTotal(variety.id);
|
const statTotal = pokemon.baseStatTotal(variety.id);
|
||||||
const repeat = {
|
const repeat = {
|
||||||
hp: Math.round((variety.stats.hp / 255) * 10) * 2,
|
hp: Math.round((variety.stats.hp / 255) * 10) * 2,
|
||||||
atk: Math.round((variety.stats.atk / 255) * 10) * 2,
|
atk: Math.round((variety.stats.atk / 255) * 10) * 2,
|
||||||
@@ -76,8 +74,12 @@ module.exports = class PokedexCommand extends Command {
|
|||||||
};
|
};
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0xED1C24)
|
.setColor(0xED1C24)
|
||||||
.setAuthor(`#${data.displayID} - ${data.name}`, data.formBoxImageURL(variety.id), data.serebiiURL)
|
.setAuthor(
|
||||||
.setThumbnail(data.formSpriteImageURL(variety.id))
|
`#${pokemon.displayID} - ${pokemon.name}`,
|
||||||
|
pokemon.formBoxImageURL(variety.id),
|
||||||
|
pokemon.serebiiURL
|
||||||
|
)
|
||||||
|
.setThumbnail(pokemon.formSpriteImageURL(variety.id))
|
||||||
.addField(`❯ Base Stats (${variety.name || 'Base'} Form)`, stripIndents`
|
.addField(`❯ Base Stats (${variety.name || 'Base'} Form)`, stripIndents`
|
||||||
\`HP: [${'█'.repeat(repeat.hp)}${' '.repeat(20 - repeat.hp)}]\` **${variety.stats.hp}**
|
\`HP: [${'█'.repeat(repeat.hp)}${' '.repeat(20 - repeat.hp)}]\` **${variety.stats.hp}**
|
||||||
\`Attack: [${'█'.repeat(repeat.atk)}${' '.repeat(20 - repeat.atk)}]\` **${variety.stats.atk}**
|
\`Attack: [${'█'.repeat(repeat.atk)}${' '.repeat(20 - repeat.atk)}]\` **${variety.stats.atk}**
|
||||||
@@ -90,7 +92,7 @@ module.exports = class PokedexCommand extends Command {
|
|||||||
`)
|
`)
|
||||||
.addField('❯ Abilities', variety.abilities.map(ability => ability.name).join('/'))
|
.addField('❯ Abilities', variety.abilities.map(ability => ability.name).join('/'))
|
||||||
.addField('❯ Other Forms', stripIndents`
|
.addField('❯ Other Forms', stripIndents`
|
||||||
_Use ${this.usage(`${data.id} <form>`)} to get stats for another form._
|
_Use ${this.usage(`${pokemon.id} <form>`)} to get stats for another form._
|
||||||
|
|
||||||
**Forms Available:** ${displayForms.map(vrity => `\`${vrity.name || 'Normal'}\``).join(', ')}
|
**Forms Available:** ${displayForms.map(vrity => `\`${vrity.name || 'Normal'}\``).join(', ')}
|
||||||
`);
|
`);
|
||||||
|
|||||||
+23
-24
@@ -63,7 +63,7 @@ module.exports = class PokedexCommand extends Command {
|
|||||||
{
|
{
|
||||||
key: 'pokemon',
|
key: 'pokemon',
|
||||||
prompt: 'What Pokémon would you like to get information on?',
|
prompt: 'What Pokémon would you like to get information on?',
|
||||||
type: 'string'
|
type: 'pokemon'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -71,52 +71,51 @@ module.exports = class PokedexCommand extends Command {
|
|||||||
|
|
||||||
async run(msg, { pokemon }) {
|
async run(msg, { pokemon }) {
|
||||||
try {
|
try {
|
||||||
const data = await this.client.pokemon.fetch(pokemon);
|
if (!pokemon.gameDataCached) await pokemon.fetchGameData();
|
||||||
if (!data) return msg.say('Could not find any results.');
|
const defaultVariety = pokemon.varieties.find(variety => variety.default);
|
||||||
if (!data.gameDataCached) await data.fetchGameData();
|
const typesShown = pokemon.varieties.filter(variety => {
|
||||||
const defaultVariety = data.varieties.find(variety => variety.default);
|
|
||||||
const typesShown = data.varieties.filter(variety => {
|
|
||||||
if (variety.default) return true;
|
if (variety.default) return true;
|
||||||
return !arrayEquals(defaultVariety.types, variety.types);
|
return !arrayEquals(defaultVariety.types, variety.types);
|
||||||
});
|
});
|
||||||
const feet = Math.floor(data.height / 12);
|
const feet = Math.floor(pokemon.height / 12);
|
||||||
const evoChain = data.chain.data.map(pkmn => {
|
const evoChain = pokemon.chain.data.map(pkmn => {
|
||||||
if (Array.isArray(pkmn)) {
|
if (Array.isArray(pkmn)) {
|
||||||
return pkmn.map(pkmn2 => {
|
return pkmn.map(pkmn2 => {
|
||||||
const found = this.client.pokemon.get(pkmn2);
|
const found = this.client.pokemon.get(pkmn2);
|
||||||
if (found.id === data.id) return `**${found.name}**`;
|
if (found.id === pokemon.id) return `**${found.name}**`;
|
||||||
return found.name;
|
return found.name;
|
||||||
}).join('/');
|
}).join('/');
|
||||||
}
|
}
|
||||||
const found = this.client.pokemon.get(pkmn);
|
const found = this.client.pokemon.get(pkmn);
|
||||||
if (found.id === data.id) return `**${found.name}**`;
|
if (found.id === pokemon.id) return `**${found.name}**`;
|
||||||
return found.name;
|
return found.name;
|
||||||
}).join(' -> ');
|
}).join(' -> ');
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0xED1C24)
|
.setColor(0xED1C24)
|
||||||
.setAuthor(`#${data.displayID} - ${data.name}`, data.boxImageURL, data.serebiiURL)
|
.setAuthor(`#${pokemon.displayID} - ${pokemon.name}`, pokemon.boxImageURL, pokemon.serebiiURL)
|
||||||
.setDescription(stripIndents`
|
.setDescription(stripIndents`
|
||||||
**${data.genus}**
|
**${pokemon.genus}**
|
||||||
${data.entries[Math.floor(Math.random() * data.entries.length)]}
|
${pokemon.entries[Math.floor(Math.random() * pokemon.entries.length)]}
|
||||||
`)
|
`)
|
||||||
.setThumbnail(data.spriteImageURL)
|
.setThumbnail(pokemon.spriteImageURL)
|
||||||
.addField('❯ Introduced In', games[genGames[data.generation]], true)
|
.addField('❯ Introduced In', games[genGames[pokemon.generation]], true)
|
||||||
.addField('❯ Height', `${feet}'${Math.floor(data.height) - (feet * 12)}"`, true)
|
.addField('❯ Height', `${feet}'${Math.floor(pokemon.height) - (feet * 12)}"`, true)
|
||||||
.addField('❯ Weight', `${data.weight} lbs.`, true)
|
.addField('❯ Weight', `${pokemon.weight} lbs.`, true)
|
||||||
.addField('❯ Types', typesShown.map(variety => {
|
.addField('❯ Types', typesShown.map(variety => {
|
||||||
const showParens = variety.name && typesShown.length > 1;
|
const showParens = variety.name && typesShown.length > 1;
|
||||||
return `${variety.types.join('/')}${showParens ? ` (${variety.name})` : ''}`;
|
return `${variety.types.join('/')}${showParens ? ` (${variety.name})` : ''}`;
|
||||||
}).join('\n'))
|
}).join('\n'))
|
||||||
.addField('❯ Evolution Chain', `${evoChain}${data.mega ? ` -> ${this.megaEvolveEmoji}` : ''}`)
|
.addField('❯ Evolution Chain', `${evoChain}${pokemon.mega ? ` -> ${this.megaEvolveEmoji}` : ''}`)
|
||||||
.addField('❯ Held Items', data.heldItems.length
|
.addField('❯ Held Items', pokemon.heldItems.length
|
||||||
? data.heldItems.map(item => `${item.data.name} (${item.rarity}%)`).join('\n')
|
? pokemon.heldItems.map(item => `${item.data.name} (${item.rarity}%)`).join('\n')
|
||||||
: 'None')
|
: 'None')
|
||||||
.addField('❯ Gender Rate',
|
.addField('❯ Gender Rate', pokemon.genderRate.genderless
|
||||||
data.genderRate.genderless ? 'Genderless' : `♂️ ${data.genderRate.male}% ♀️ ${data.genderRate.female}%`);
|
? 'Genderless'
|
||||||
if (data.cry) {
|
: `♂️ ${pokemon.genderRate.male}% ♀️ ${pokemon.genderRate.female}%`);
|
||||||
|
if (pokemon.cry) {
|
||||||
const connection = msg.guild ? this.client.voice.connections.get(msg.guild.id) : null;
|
const connection = msg.guild ? this.client.voice.connections.get(msg.guild.id) : null;
|
||||||
if (connection) {
|
if (connection) {
|
||||||
connection.play(data.cry);
|
connection.play(pokemon.cry);
|
||||||
await reactIfAble(msg, this.client.user, '🔉');
|
await reactIfAble(msg, this.client.user, '🔉');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ module.exports = class SmogonCommand extends Command {
|
|||||||
{
|
{
|
||||||
key: 'pokemon',
|
key: 'pokemon',
|
||||||
prompt: 'What Pokémon would you like to get information on?',
|
prompt: 'What Pokémon would you like to get information on?',
|
||||||
type: 'string'
|
type: 'pokemon'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -55,16 +55,15 @@ module.exports = class SmogonCommand extends Command {
|
|||||||
|
|
||||||
async run(msg, { pokemon }) {
|
async run(msg, { pokemon }) {
|
||||||
try {
|
try {
|
||||||
const data = await this.client.pokemon.fetch(pokemon);
|
const fetchGames = genGames.slice(pokemon.generation, pokemon.missingno ? 2 : genGames.length);
|
||||||
if (!data) return msg.say('Could not find any results.');
|
if (!pokemon.missingno) await pokemon.fetchSmogonTiers(...fetchGames);
|
||||||
const fetchGames = genGames.slice(data.generation, data.missingno ? 2 : genGames.length);
|
|
||||||
if (!data.missingno) await data.fetchSmogonTiers(...fetchGames);
|
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0xED1C24)
|
.setColor(0xED1C24)
|
||||||
.setAuthor(`#${data.displayID} - ${data.name}`, data.boxImageURL, data.serebiiURL)
|
.setAuthor(`#${pokemon.displayID} - ${pokemon.name}`, pokemon.boxImageURL, pokemon.serebiiURL)
|
||||||
.setThumbnail(data.spriteImageURL);
|
.setThumbnail(pokemon.spriteImageURL);
|
||||||
for (const game of fetchGames) {
|
for (const game of fetchGames) {
|
||||||
embed.addField(`❯ ${games[game]}`, `[${data.smogonTiers[game].join('/')}](${data.smogonURL(game)})`, true);
|
embed.addField(`❯ ${games[game]}`,
|
||||||
|
`[${pokemon.smogonTiers[game].join('/')}](${pokemon.smogonURL(game)})`, true);
|
||||||
}
|
}
|
||||||
if (fetchGames.length % 3 !== 0 && fetchGames.length > 3) {
|
if (fetchGames.length % 3 !== 0 && fetchGames.length > 3) {
|
||||||
for (let i = 0; i < 3 - (fetchGames.length % 3); i++) {
|
for (let i = 0; i < 3 - (fetchGames.length % 3); i++) {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "129.3.0",
|
"version": "129.4.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
const { ArgumentType } = require('discord.js-commando');
|
||||||
|
|
||||||
|
module.exports = class PokemonArgumentType extends ArgumentType {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, 'pokemon');
|
||||||
|
}
|
||||||
|
|
||||||
|
async validate(value) {
|
||||||
|
const data = await this.client.pokemon.fetch(value);
|
||||||
|
if (!data) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async parse(value) {
|
||||||
|
return this.client.pokemon.fetch(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user