mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 06:42:50 +02:00
Advice slip Command
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
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 { raw } = await snekfetch.get('http://api.adviceslip.com/advice');
|
||||
return msg.say(JSON.parse(raw.toString()).slip.advice);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user