Haha-Yes/commands/general/advice.js

33 lines
775 B
JavaScript
Raw Normal View History

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()
2019-11-02 00:54:40 +01:00
.setColor(message.member.displayHexColor)
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;