mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Add height, weight, class, and gender rate to pokemon
This commit is contained in:
@@ -56,6 +56,10 @@
|
||||
"evolution_chain": {
|
||||
"url": null
|
||||
},
|
||||
"is_legendary": false,
|
||||
"is_mythical": false,
|
||||
"is_baby": false,
|
||||
"gender_rate": -1,
|
||||
"stats": {
|
||||
"hp": 33,
|
||||
"atk": 136,
|
||||
@@ -64,6 +68,8 @@
|
||||
"sDef": 6,
|
||||
"spd": 29
|
||||
},
|
||||
"height": 120,
|
||||
"weight": 3507.2,
|
||||
"abilities": ["N/A"],
|
||||
"chain": [0],
|
||||
"missingno": true,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { reactIfAble } = require('../../util/Util');
|
||||
const { firstUpperCase, reactIfAble } = require('../../util/Util');
|
||||
|
||||
module.exports = class PokedexCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -72,6 +72,7 @@ module.exports = class PokedexCommand extends Command {
|
||||
spd: Math.round((data.stats.spd / 255) * 10) * 2,
|
||||
total: Math.round((data.baseStatTotal / 720) * 10) * 2
|
||||
};
|
||||
const feet = Math.floor(data.height / 12);
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xED1C24)
|
||||
.setAuthor(`#${data.displayID} - ${data.name}`, data.boxImageURL, data.serebiiURL)
|
||||
@@ -80,6 +81,9 @@ module.exports = class PokedexCommand extends Command {
|
||||
${data.entries[Math.floor(Math.random() * data.entries.length)]}
|
||||
`)
|
||||
.setThumbnail(data.spriteImageURL)
|
||||
.addField('❯ Class', firstUpperCase(data.class), true)
|
||||
.addField('❯ Height', `${feet}'${Math.round(data.height % 12)}"`, true)
|
||||
.addField('❯ Weight', `${data.weight} lbs.`, true)
|
||||
.addField('❯ Types', typesShown.map(variety => {
|
||||
const showParens = variety.name && typesShown.length > 1;
|
||||
return `${variety.types.join('/')}${showParens ? ` (${variety.name})` : ''}`;
|
||||
@@ -106,7 +110,9 @@ module.exports = class PokedexCommand extends Command {
|
||||
\`-----------------------------------\`
|
||||
\`Total: [${'█'.repeat(repeat.total)}${' '.repeat(20 - repeat.total)}]\` **${data.baseStatTotal}**
|
||||
`)
|
||||
.addField('❯ Abilities', data.abilities.join(' / '));
|
||||
.addField('❯ Abilities', data.abilities.join(' / '))
|
||||
.addField('❯ Gender Rate',
|
||||
data.genderRate.genderless ? 'Genderless' : `♂️ ${data.genderRate.male}% ♀️ ${data.genderRate.female}%`);
|
||||
if (data.cry) {
|
||||
const connection = msg.guild ? this.client.voice.connections.get(msg.guild.id) : null;
|
||||
if (connection) {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "123.2.2",
|
||||
"version": "123.2.3",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -20,6 +20,14 @@ module.exports = class Pokemon {
|
||||
this.genus = data.genera.length
|
||||
? `The ${data.genera.filter(entry => entry.language.name === 'en')[0].genus}`
|
||||
: 'Undiscovered Pokémon';
|
||||
this.genderRate = {
|
||||
male: data.gender_rate === -1 ? 0 : 100 - ((data.gender_rate / 8) * 100),
|
||||
female: data.gender_rate === -1 ? 0 : (data.gender_rate / 8) * 100,
|
||||
genderless: data.gender_rate === -1
|
||||
};
|
||||
this.legendary = data.is_legendary;
|
||||
this.mythical = data.is_mythical;
|
||||
this.baby = data.is_baby;
|
||||
this.varieties = data.varieties.map(variety => {
|
||||
const name = firstUpperCase(variety.pokemon.name
|
||||
.replace(new RegExp(`${this.slug}-?`, 'i'), '')
|
||||
@@ -38,6 +46,8 @@ module.exports = class Pokemon {
|
||||
};
|
||||
this.stats = data.missingno ? data.stats : null;
|
||||
this.abilities = data.missingno ? data.abilities : [];
|
||||
this.height = data.missingno ? data.height : null;
|
||||
this.weight = data.missingno ? data.weight : null;
|
||||
this.gameDataCached = data.missingno || false;
|
||||
this.missingno = data.missingno || false;
|
||||
this.cry = data.id > store.pokemonCountWithCry
|
||||
@@ -50,6 +60,14 @@ module.exports = class Pokemon {
|
||||
return this.stats.hp + this.stats.atk + this.stats.def + this.stats.sAtk + this.stats.sDef + this.stats.spd;
|
||||
}
|
||||
|
||||
get class() {
|
||||
if (this.legendary) return 'legendary';
|
||||
if (this.mythical) return 'mythical';
|
||||
if (this.baby) return 'baby';
|
||||
if (this.missingno) return 'glitch';
|
||||
return 'standard';
|
||||
}
|
||||
|
||||
get displayID() {
|
||||
if (this.missingno) return '???';
|
||||
return this.id.toString().padStart(3, '0');
|
||||
@@ -61,6 +79,7 @@ module.exports = class Pokemon {
|
||||
|
||||
get spriteImageURL() {
|
||||
if (this.missingno) return missingno.sprite;
|
||||
if (this.id === 898) return 'https://assets.pokemon.com/assets/cms2/img/pokedex/full/898.png';
|
||||
return `https://serebii.net/pokemon/art/${this.displayID}.png`;
|
||||
}
|
||||
|
||||
@@ -102,6 +121,8 @@ module.exports = class Pokemon {
|
||||
const { body } = await request.get(ability.ability.url);
|
||||
this.abilities.push(body.names.find(name => name.language.name === 'en').name);
|
||||
}
|
||||
this.height = defaultBody.height * 3.94;
|
||||
this.weight = defaultBody.weight * 0.2205;
|
||||
await this.fetchChain();
|
||||
this.gameDataCached = true;
|
||||
return this;
|
||||
|
||||
@@ -7,7 +7,7 @@ module.exports = class PokemonStore extends Collection {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
this.pokemonCount = 897;
|
||||
this.pokemonCount = 898;
|
||||
this.pokemonCountWithCry = 893;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user