2018-12-30 01:20:24 +01:00
|
|
|
const { Command } = require('discord-akairo');
|
|
|
|
const fetch = require('node-fetch');
|
|
|
|
|
|
|
|
class AdviceCommand extends Command {
|
2019-01-02 08:09:45 +01:00
|
|
|
constructor() {
|
|
|
|
super('advice', {
|
|
|
|
aliases: ['advice'],
|
|
|
|
category: 'general',
|
2019-11-09 12:04:01 +01:00
|
|
|
clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'],
|
2019-01-02 08:09:45 +01:00
|
|
|
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-11-22 12:30:20 +01:00
|
|
|
const adviceEmbed = this.client.util.embed()
|
2020-03-22 21:54:19 +01:00
|
|
|
.setColor(message.member ? message.member.displayHexColor : 'NAVY')
|
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;
|