Files
xiao/commands/random/advice-slip.js
T
Daniel Odendahl Jr 8725e348be snekfetch -> superagent
2018-06-07 16:02:53 +00:00

24 lines
622 B
JavaScript

const Command = require('../../structures/Command');
const request = require('superagent');
module.exports = class AdviceSlipCommand extends Command {
constructor(client) {
super(client, {
name: 'advice-slip',
aliases: ['advice'],
group: 'random',
memberName: 'advice-slip',
description: 'Responds with a random bit of advice.'
});
}
async run(msg) {
try {
const { text } = await request.get('http://api.adviceslip.com/advice');
return msg.say(JSON.parse(text).slip.advice);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};