mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 14:21:41 +02:00
Clean-up
This commit is contained in:
@@ -2,7 +2,6 @@ const { Command } = require('discord.js-commando');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { filterPkmn } = require('../../util/Util');
|
||||
|
||||
module.exports = class PokedexCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -31,13 +30,13 @@ module.exports = class PokedexCommand extends Command {
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xED1C24)
|
||||
.setAuthor(
|
||||
`#${id} - ${filterPkmn(body.names).name}`,
|
||||
`#${id} - ${this.filterPokemonData(body.names, false).name}`,
|
||||
`https://www.serebii.net/pokedex-sm/icon/${id}.png`,
|
||||
`https://www.serebii.net/pokedex-sm/${id}.shtml`
|
||||
)
|
||||
.setDescription(stripIndents`
|
||||
**The ${filterPkmn(body.genera).genus}**
|
||||
${filterPkmn(body.flavor_text_entries).flavor_text.replace(/\n|\f|\r/g, ' ')}
|
||||
**The ${this.filterPokemonData(body.genera, false).genus}**
|
||||
${this.filterPokemonData(body.flavor_text_entries).flavor_text.replace(/\n|\f|\r/g, ' ')}
|
||||
`)
|
||||
.setThumbnail(`https://www.serebii.net/sunmoon/pokemon/${id}.png`);
|
||||
return msg.embed(embed);
|
||||
@@ -46,4 +45,9 @@ module.exports = class PokedexCommand extends Command {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
filterPokemonData(arr, random = true) {
|
||||
const filtered = arr.filter(entry => entry.language.name === 'en');
|
||||
return filtered[random ? Math.floor(Math.random() * filtered.length) : 0];
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user