diff --git a/commands/image-edit/pokemon-fusion.js b/commands/image-edit/pokemon-fusion.js index 6c15a7d2..7859626c 100644 --- a/commands/image-edit/pokemon-fusion.js +++ b/commands/image-edit/pokemon-fusion.js @@ -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`] }); } }; diff --git a/commands/search/pokedex.js b/commands/search/pokedex.js new file mode 100644 index 00000000..38cab36a --- /dev/null +++ b/commands/search/pokedex.js @@ -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]; + } +}; diff --git a/commands/user-info/avatar.js b/commands/user-info/avatar.js index e714f4b1..96997460 100644 --- a/commands/user-info/avatar.js +++ b/commands/user-info/avatar.js @@ -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); } }; diff --git a/html/carbonfeat.html b/html/carbonfeat.html index 69f28788..071a89ee 100644 --- a/html/carbonfeat.html +++ b/html/carbonfeat.html @@ -49,6 +49,7 @@