Pokemon Held Item Data

This commit is contained in:
Dragon Fire
2020-12-10 08:30:54 -05:00
parent 50611d8bd9
commit 0c8133c6d5
4 changed files with 23 additions and 2 deletions
+1
View File
@@ -31,6 +31,7 @@
"genus": "??? Pokémon"
}
],
"held_items": [],
"varieties": [
{
"is_default": true,
+2 -1
View File
@@ -122,6 +122,7 @@ module.exports = class PokedexCommand extends Command {
const showParens = variety.name && abilitiesShown.length > 1;
return `${variety.abilities.join('/')}${showParens ? ` (${variety.name})` : ''}`;
}).join('\n'))
.addField(' Held Items', data.heldItems.length ? data.heldItems.map(item => item.name).join('/') : 'None')
.addField(' Gender Rate',
data.genderRate.genderless ? 'Genderless' : `♂️ ${data.genderRate.male}% ♀️ ${data.genderRate.female}%`);
if (data.cry) {
@@ -134,8 +135,8 @@ module.exports = class PokedexCommand extends Command {
} else {
const usage = this.client.registry.commands.get('join').usage();
embed.setFooter(stripIndents`
Join a voice channel and use ${usage} to hear the Pokémon's cry.
Use ${moveUsage} to get the Pokémon's moveset.
Join a voice channel and use ${usage} to hear the Pokémon's cry.
`);
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "123.4.1",
"version": "123.4.2",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {
+19
View File
@@ -28,6 +28,16 @@ module.exports = class Pokemon {
this.legendary = data.is_legendary;
this.mythical = data.is_mythical;
this.baby = data.is_baby;
this.heldItems = data.held_items
.filter(item => item.version_details.some(version => {
const inSwordShield = version.version.name === 'sword' || version.version.name === 'shield';
if (inSwordShield) return true;
if (!inSwordShield && (version.version.name === 'ultra-sun' || version.version.name === 'ultra-moon')) {
return true;
}
return false;
}))
.map(item => ({ url: item.item.url, name: null }));
this.varieties = data.varieties.map(variety => {
const name = firstUpperCase(variety.pokemon.name
.replace(new RegExp(`${this.slug}-?`, 'i'), '')
@@ -135,6 +145,7 @@ module.exports = class Pokemon {
}
this.height = defaultBody.height * 3.94;
this.weight = defaultBody.weight * 0.2205;
await this.fetchHeldItemNames();
await this.fetchChain();
this.gameDataCached = true;
return this;
@@ -165,4 +176,12 @@ module.exports = class Pokemon {
}
return this.chain.data;
}
async fetchHeldItemNames() {
for (const item of this.heldItems) {
const { body } = await request.get(item.url);
item.name = body.names.find(name => name.language.name === 'en').name;
}
return this.heldItems;
}
};