Haha-Yes/commands/general/advice.js

33 lines
740 B
JavaScript
Raw Normal View History

2018-12-30 01:20:24 +01:00
const { Command } = require('discord-akairo');
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;