mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 05:49:49 +02:00
Add height, weight, class, and gender rate to pokemon
This commit is contained in:
@@ -56,6 +56,10 @@
|
|||||||
"evolution_chain": {
|
"evolution_chain": {
|
||||||
"url": null
|
"url": null
|
||||||
},
|
},
|
||||||
|
"is_legendary": false,
|
||||||
|
"is_mythical": false,
|
||||||
|
"is_baby": false,
|
||||||
|
"gender_rate": -1,
|
||||||
"stats": {
|
"stats": {
|
||||||
"hp": 33,
|
"hp": 33,
|
||||||
"atk": 136,
|
"atk": 136,
|
||||||
@@ -64,6 +68,8 @@
|
|||||||
"sDef": 6,
|
"sDef": 6,
|
||||||
"spd": 29
|
"spd": 29
|
||||||
},
|
},
|
||||||
|
"height": 120,
|
||||||
|
"weight": 3507.2,
|
||||||
"abilities": ["N/A"],
|
"abilities": ["N/A"],
|
||||||
"chain": [0],
|
"chain": [0],
|
||||||
"missingno": true,
|
"missingno": true,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { reactIfAble } = require('../../util/Util');
|
const { firstUpperCase, reactIfAble } = require('../../util/Util');
|
||||||
|
|
||||||
module.exports = class PokedexCommand extends Command {
|
module.exports = class PokedexCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -72,6 +72,7 @@ module.exports = class PokedexCommand extends Command {
|
|||||||
spd: Math.round((data.stats.spd / 255) * 10) * 2,
|
spd: Math.round((data.stats.spd / 255) * 10) * 2,
|
||||||
total: Math.round((data.baseStatTotal / 720) * 10) * 2
|
total: Math.round((data.baseStatTotal / 720) * 10) * 2
|
||||||
};
|
};
|
||||||
|
const feet = Math.floor(data.height / 12);
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0xED1C24)
|
.setColor(0xED1C24)
|
||||||
.setAuthor(`#${data.displayID} - ${data.name}`, data.boxImageURL, data.serebiiURL)
|
.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)]}
|
${data.entries[Math.floor(Math.random() * data.entries.length)]}
|
||||||
`)
|
`)
|
||||||
.setThumbnail(data.spriteImageURL)
|
.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 => {
|
.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})` : ''}`;
|
||||||
@@ -106,7 +110,9 @@ module.exports = class PokedexCommand extends Command {
|
|||||||
\`-----------------------------------\`
|
\`-----------------------------------\`
|
||||||
\`Total: [${'█'.repeat(repeat.total)}${' '.repeat(20 - repeat.total)}]\` **${data.baseStatTotal}**
|
\`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) {
|
if (data.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) {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "123.2.2",
|
"version": "123.2.3",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -20,6 +20,14 @@ module.exports = class Pokemon {
|
|||||||
this.genus = data.genera.length
|
this.genus = data.genera.length
|
||||||
? `The ${data.genera.filter(entry => entry.language.name === 'en')[0].genus}`
|
? `The ${data.genera.filter(entry => entry.language.name === 'en')[0].genus}`
|
||||||
: 'Undiscovered Pokémon';
|
: '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 => {
|
this.varieties = data.varieties.map(variety => {
|
||||||
const name = firstUpperCase(variety.pokemon.name
|
const name = firstUpperCase(variety.pokemon.name
|
||||||
.replace(new RegExp(`${this.slug}-?`, 'i'), '')
|
.replace(new RegExp(`${this.slug}-?`, 'i'), '')
|
||||||
@@ -38,6 +46,8 @@ module.exports = class Pokemon {
|
|||||||
};
|
};
|
||||||
this.stats = data.missingno ? data.stats : null;
|
this.stats = data.missingno ? data.stats : null;
|
||||||
this.abilities = data.missingno ? data.abilities : [];
|
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.gameDataCached = data.missingno || false;
|
||||||
this.missingno = data.missingno || false;
|
this.missingno = data.missingno || false;
|
||||||
this.cry = data.id > store.pokemonCountWithCry
|
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;
|
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() {
|
get displayID() {
|
||||||
if (this.missingno) return '???';
|
if (this.missingno) return '???';
|
||||||
return this.id.toString().padStart(3, '0');
|
return this.id.toString().padStart(3, '0');
|
||||||
@@ -61,6 +79,7 @@ module.exports = class Pokemon {
|
|||||||
|
|
||||||
get spriteImageURL() {
|
get spriteImageURL() {
|
||||||
if (this.missingno) return missingno.sprite;
|
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`;
|
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);
|
const { body } = await request.get(ability.ability.url);
|
||||||
this.abilities.push(body.names.find(name => name.language.name === 'en').name);
|
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();
|
await this.fetchChain();
|
||||||
this.gameDataCached = true;
|
this.gameDataCached = true;
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ module.exports = class PokemonStore extends Collection {
|
|||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
|
|
||||||
this.pokemonCount = 897;
|
this.pokemonCount = 898;
|
||||||
this.pokemonCountWithCry = 893;
|
this.pokemonCountWithCry = 893;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user