Files
xiao/commands/random-res/dog.js
T
2017-10-24 19:02:27 +00:00

25 lines
644 B
JavaScript

const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
module.exports = class DogCommand extends Command {
constructor(client) {
super(client, {
name: 'dog',
aliases: ['puppy'],
group: 'random-res',
memberName: 'dog',
description: 'Responds with a random dog image.',
clientPermissions: ['ATTACH_FILES']
});
}
async run(msg) {
try {
const { body } = await snekfetch.get('https://dog.ceo/api/breeds/image/random');
return msg.say({ files: [body.message] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};