Files
xiao/commands/random-res/joke.js
T
Daniel Odendahl Jr eed39c5ec1 Catch every API
2017-08-27 22:04:58 +00:00

25 lines
596 B
JavaScript

const Command = require('../../structures/Command');
const snekfetch = require('snekfetch');
module.exports = class JokeCommand extends Command {
constructor(client) {
super(client, {
name: 'joke',
group: 'random-res',
memberName: 'joke',
description: 'Responds with a random joke.'
});
}
async run(msg) {
try {
const { body } = await snekfetch
.get('https://icanhazdadjoke.com/')
.set({ Accept: 'application/json' });
return msg.say(body.joke);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};