2018-12-30 01:20:24 +01:00
|
|
|
const { Command } = require('discord-akairo');
|
2019-01-02 10:21:21 +01:00
|
|
|
const { MessageEmbed } = require('discord.js');
|
2018-12-30 01:20:24 +01:00
|
|
|
const fetch = require('node-fetch');
|
|
|
|
|
|
|
|
class AdviceCommand extends Command {
|
2019-01-02 08:09:45 +01:00
|
|
|
constructor() {
|
|
|
|
super('advice', {
|
|
|
|
aliases: ['advice'],
|
|
|
|
category: 'general',
|
|
|
|
description: {
|
2018-12-30 01:20:24 +01:00
|
|
|
content: 'Send some random advices',
|
|
|
|
usage: '',
|
|
|
|
examples: ['']
|
|
|
|
}
|
2019-01-02 08:09:45 +01:00
|
|
|
});
|
|
|
|
}
|
2018-12-30 01:20:24 +01:00
|
|
|
|
2019-01-02 08:09:45 +01:00
|
|
|
async exec(message) {
|
|
|
|
fetch('http://api.adviceslip.com/advice').then((response) => {
|
|
|
|
return response.json();
|
|
|
|
}).then((response) => {
|
2019-01-02 18:45:53 +01:00
|
|
|
const adviceEmbed = new MessageEmbed()
|
|
|
|
.setColor('#ff9900')
|
2019-01-02 08:09:45 +01:00
|
|
|
.setTitle(response.slip.slip_id)
|
|
|
|
.setDescription(response.slip.advice);
|
2018-12-30 01:20:24 +01:00
|
|
|
|
|
|
|
|
2019-01-02 08:09:45 +01:00
|
|
|
message.channel.send(adviceEmbed);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
2018-12-30 01:20:24 +01:00
|
|
|
}
|
|
|
|
module.exports = AdviceCommand;
|