Random Dog Command

This commit is contained in:
Daniel Odendahl Jr
2017-04-27 16:14:53 +00:00
parent 979081eca1
commit d1ae560193
6 changed files with 31 additions and 3 deletions
+26
View File
@@ -0,0 +1,26 @@
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.');
}
}
};