Pokédex Command

This commit is contained in:
Daniel Odendahl Jr
2017-07-27 04:31:36 +00:00
parent 05210f7fe2
commit 1a470682ef
6 changed files with 64 additions and 3 deletions
+1 -1
View File
@@ -36,6 +36,6 @@ module.exports = class PokemonFusionCommand extends Command {
run(msg, args) {
const { source1, source2 } = args;
return msg.say(`http://images.alexonsager.net/pokemon/fused/${source1}/${source1}.${source2}.png`);
return msg.say({ files: [`http://images.alexonsager.net/pokemon/fused/${source1}/${source1}.${source2}.png`] });
}
};
+54
View File
@@ -0,0 +1,54 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { stripIndents } = require('common-tags');
module.exports = class PokedexCommand extends Command {
constructor(client) {
super(client, {
name: 'pokedex',
aliases: ['pokemon', 'pokémon', 'pokédex'],
group: 'search',
memberName: 'pokedex',
description: 'Searches the Pokédex for a Pokémon.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'pokemon',
prompt: 'What Pokémon would you like to search for?',
type: 'string',
parse: (pokemon) => pokemon.toLowerCase().replace(/[ ]/g, '-')
}
]
});
}
async run(msg, args) {
const { pokemon } = args;
try {
const { body } = await snekfetch
.get(`https://pokeapi.co/api/v2/pokemon-species/${pokemon}`);
const id = `${'000'.slice(body.id.toString().length)}${body.id}`;
const name = this.filter(body.names).name;
const flavor = this.filter(body.flavor_text_entries).flavor_text;
const species = this.filter(body.genera).genus;
const embed = new MessageEmbed()
.setColor(0xED1C24)
.setAuthor(`#${id} - ${name}`, `https://www.serebii.net/pokedex-sm/icon/${id}.png`)
.setURL(`https://www.serebii.net/pokedex-sm/${id}.shtml`)
.setDescription(stripIndents`
**The ${species} Pokémon**
${flavor}
`)
.setThumbnail(`https://www.serebii.net/sunmoon/pokemon/${id}.png`);
return msg.embed(embed);
} catch (err) {
if (err.status === 404) return msg.say('Pokémon Not Found.');
else throw err;
}
}
filter(arr) {
return arr.filter((entry) => entry.language.name === 'en')[0];
}
};
+6 -1
View File
@@ -20,6 +20,11 @@ module.exports = class AvatarCommand extends Command {
run(msg, args) {
const user = args.user || msg.author;
return msg.say(user.displayAvatarURL({ size: 2048 }));
if (!user.avatar) return msg.say('This user has no avatar.');
const avatar = user.avatarURL({
format: user.avatar.startsWith('a_') ? 'gif' : 'png',
size: 2048
});
return msg.say(avatar);
}
};
+1
View File
@@ -49,6 +49,7 @@
<li>Neopets</li>
<li>NPM</li>
<li>osu!</li>
<li>Pokédex</li>
<li>Recipe Puppy</li>
<li>Reddit</li>
<li>Rule34</li>
+1
View File
@@ -46,6 +46,7 @@
<li>Neopets</li>
<li>NPM</li>
<li>osu!</li>
<li>Pokédex</li>
<li>Recipe Puppy</li>
<li>Reddit</li>
<li>Rule34</li>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "27.8.1",
"version": "27.9.0",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {