Files
xiao/commands/randomimg/dog.js
T
Daniel Odendahl Jr d1ae560193 Random Dog Command
2017-04-27 16:14:53 +00:00

27 lines
879 B
JavaScript

const { Command } = require('discord.js-commando');
const request = require('superagent');
module.exports = class DogCommand extends Command {
constructor(client) {
super(client, {
name: 'dog',
group: 'randomimg',
memberName: 'dog',
description: 'Sends a random dog image.'
});
}
async run(message) {
if (message.channel.type !== 'dm')
if (!message.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return message.say('This Command requires the `Attach Files` Permission.');
try {
const { body } = await request
.get('https://random.dog/woof.json');
return message.channel.send({files: [body.url]});
} catch (err) {
return message.say('An Unknown Error Occurred.');
}
}
};