auto-hide empty fields

This commit is contained in:
Emily 2020-11-06 14:42:23 +11:00
parent 04f4c8d141
commit ef2a2d1a0c
1 changed files with 15 additions and 15 deletions

View File

@ -1,5 +1,5 @@
const Embed = require('../../util/embed'); const Embed = require('../../util/embed');
const colours = require('../../assets/constants/typeColours.json'); const { colours } = require('../../assets/constants/pokemon.json');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
module.exports = class { module.exports = class {
@ -85,7 +85,7 @@ module.exports = class {
const abilities = this.parseAbilities(pokemon.abilities); const abilities = this.parseAbilities(pokemon.abilities);
let sprite = pokemon.sprite; let sprite = pokemon.sprite;
if (Math.floor((Math.random() * 100) + 1) === 69) sprite = pokemon.shinySprite; if (Math.floor((Math.random() * 100) + 1) === 69) sprite = pokemon.shinySprite;
let formes = '(No Alternate Formes)'; let formes;
if (pokemon.otherFormes) { if (pokemon.otherFormes) {
formes = pokemon.otherFormes.join(', '); formes = pokemon.otherFormes.join(', ');
if (pokemon.cosmeticFormes) { if (pokemon.cosmeticFormes) {
@ -95,19 +95,19 @@ module.exports = class {
const embed = new Embed() const embed = new Embed()
.setColour(colours[pokemon.types[0]]) .setColour(colours[pokemon.types[0]])
.setTitle(`${pokemon.species.toProperCase()} (No. ${pokemon.num})`) .setTitle(`${pokemon.species.toProperCase()} (No. ${pokemon.num})`)
.setDescription(pokemon.flavorTexts[0].flavor) .setDescription(`\`${pokemon.flavorTexts[0].game}\` ${pokemon.flavorTexts[0].flavor}`)
.setThumbnail(sprite) .setThumbnail(sprite)
.addField('**Types:**', pokemon.types.join(', '), true) .addField('Types:', pokemon.types.join(', '), true)
.addField('**Abilities:**', abilities.join(', '), true) .addField('Abilities:', abilities.join(', '), true)
.addField('**Gender Ratio:**', genderRatio, true) .addField('Gender Ratio:', genderRatio, true)
.addField('**Base Stats:**', `**HP:** ${pokemon.baseStats.hp} **Atk:** ${pokemon.baseStats.attack} **Def:** ${pokemon.baseStats.defense} **SpA:** ${pokemon.baseStats.specialattack} **SpD:** ${pokemon.baseStats.specialdefense} **Spe:** ${pokemon.baseStats.speed} **BST:** ${pokemon.baseStatsTotal}`) .addField('Base Stats:', `HP: ${pokemon.baseStats.hp} Atk: ${pokemon.baseStats.attack} Def: ${pokemon.baseStats.defense} SpA: ${pokemon.baseStats.specialattack} SpD: ${pokemon.baseStats.specialdefense} Spe: ${pokemon.baseStats.speed} BST: ${pokemon.baseStatsTotal}`);
.addField('**Evolution Chain:**', evoChain) if (evoChain) embed.addField('Evolution Chain:', evoChain);
.addField('**Other Formes:**', formes) if (formes) embed.addField('Other Formes:', formes);
.addField('**Height:**', `${pokemon.height}m`, true) embed.addField('Height:', `${pokemon.height}m`, true);
.addField('**Weight:**', `${pokemon.weight}kg`, true) embed.addField('Weight:', `${pokemon.weight}kg`, true);
.addField('**Egg Groups:**', pokemon.eggGroups.join(', '), true) embed.addField('Egg Groups:', pokemon.eggGroups.join(', '), true);
.addField('**Smogon Tier:**', pokemon.smogonTier, true) embed.addField('Smogon Tier:', pokemon.smogonTier, true);
.addField('**External Resources:**', `[Bulbapedia](${pokemon.bulbapediaPage}) | [Serebii](${pokemon.serebiiPage}) | [Smogon](${pokemon.smogonPage})`); embed.addField('External Resources:', `[Bulbapedia](${pokemon.bulbapediaPage}) | [Serebii](${pokemon.serebiiPage}) | [Smogon](${pokemon.smogonPage})`);
message.channel.createMessage({ embed: embed }); message.channel.createMessage({ embed: embed });
}) })
.catch(err => console.log(err)); .catch(err => console.log(err));
@ -124,7 +124,7 @@ module.exports = class {
// Set evochain if there are no evolutions // Set evochain if there are no evolutions
let evoChain = `**${pokeDetails.species.toProperCase()} ${pokeDetails.evolutionLevel ? `(${pokeDetails.evolutionLevel})` : ''}**`; let evoChain = `**${pokeDetails.species.toProperCase()} ${pokeDetails.evolutionLevel ? `(${pokeDetails.evolutionLevel})` : ''}**`;
if (!pokeDetails.evolutions && !pokeDetails.preevolutions) { if (!pokeDetails.evolutions && !pokeDetails.preevolutions) {
evoChain += ' (No Evolutions)'; evoChain = null;
} }
// Parse pre-evolutions and add to evochain // Parse pre-evolutions and add to evochain