Files
xiao/commands/random-seed/adorable.js
T
Dragon Fire c61ae11679 Fix
2021-06-05 12:50:41 -04:00

46 lines
1.2 KiB
JavaScript

const Command = require('../../framework/Command');
const request = require('node-superfetch');
module.exports = class AdorableCommand extends Command {
constructor(client) {
super(client, {
name: 'adorable',
aliases: ['adorable-avatar'],
group: 'random-seed',
memberName: 'adorable',
description: 'Creates an adorable avatar based on the text you provide.',
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'Adorable Avatars',
url: 'http://avatars.adorable.io/',
reason: 'Original API'
},
{
name: 'gfauchart',
url: 'https://github.com/gfauchart',
reason: 'API',
reasonURL: 'https://github.com/adorableio/avatars-api-middleware/issues/108'
}
],
args: [
{
key: 'text',
prompt: 'What text should be used for generation?',
type: 'string',
parse: text => encodeURIComponent(text)
}
]
});
}
async run(msg, { text }) {
try {
const { body } = await request.get(`https://api.hello-avatar.com/adorables/285/${text}.png`);
return msg.say({ files: [{ attachment: body, name: 'adorable.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};