Haha-Yes/commands/fun/advice.js

33 lines
1 KiB
JavaScript
Raw Normal View History

2018-09-29 11:57:51 +02:00
const { Command } = require('discord.js-commando');
const Discord = require('discord.js');
const fetch = require('node-fetch')
2018-11-28 01:35:26 +01:00
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../blacklist');
2018-10-15 20:23:45 +02:00
2018-10-01 16:17:33 +02:00
module.exports = class AdviceCommand extends Command {
2018-09-29 11:57:51 +02:00
constructor(client) {
super(client, {
name: 'advice',
group: 'fun',
memberName: 'advice',
description: `Show some random advice`,
});
}
async run(message) {
2018-11-28 01:35:26 +01:00
let blacklistJson = new SelfReloadJSON('json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
2018-09-29 11:57:51 +02:00
fetch("http://api.adviceslip.com/advice").then((response) => {
return response.json();
}).then((response) => {
const adviceEmbed = new Discord.RichEmbed()
.setColor("#ff9900")
.setTitle(response.slip.slip_id)
.setDescription(response.slip.advice)
message.say(adviceEmbed);
});
}};