Files
xiao/commands/image-edit/pokemon-fusion.js
T
Daniel Odendahl Jr b15beb8d48 Lots of stoof
2017-10-12 02:15:40 +00:00

48 lines
1.5 KiB
JavaScript

const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
const pokemon = require('../../assets/json/pokemon-fusion');
module.exports = class PokemonFusionCommand extends Command {
constructor(client) {
super(client, {
name: 'pokemon-fusion',
aliases: ['poke-fusion', 'poke-fuse', 'pokémon-fusion', 'poké-fusion', 'poké-fuse'],
group: 'image-edit',
memberName: 'pokemon-fusion',
description: 'Fuses two Generation I Pokémon together.',
clientPermissions: ['ATTACH_FILES'],
args: [
{
key: 'body',
prompt: 'What Pokémon should be fused as the body?',
type: 'string',
validate: body => {
if (pokemon[body.toLowerCase()]) return true;
return 'Invalid body, only Pokémon from Generation I may be used.';
},
parse: body => pokemon[body.toLowerCase()]
},
{
key: 'palette',
prompt: 'What Pokémon should be fused as the palette?',
type: 'string',
validate: palette => {
if (pokemon[palette.toLowerCase()]) return true;
return 'Invalid palette, only Pokémon from Generation I may be used.';
},
parse: palette => pokemon[palette.toLowerCase()]
}
]
});
}
async run(msg, { body, palette }) {
try {
const image = await snekfetch.get(`http://images.alexonsager.net/pokemon/fused/${body}/${body}.${palette}.png`);
return msg.say({ files: [{ attachment: image.body, name: 'pokemon-fusion.png' }] });
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};