2018-10-01 16:15:52 +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-01 16:17:33 +02:00
|
|
|
module.exports = class InfoCommand extends Command {
|
2018-10-01 16:15:52 +02:00
|
|
|
constructor(client) {
|
|
|
|
super(client, {
|
|
|
|
name: 'info',
|
|
|
|
group: 'fun',
|
|
|
|
memberName: 'info',
|
|
|
|
description: `Search DuckDuckGo for answer`,
|
|
|
|
args: [
|
|
|
|
{
|
|
|
|
key: 'search',
|
|
|
|
prompt: 'What do you want me to search',
|
|
|
|
type: 'string',
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async run(message, { search }) {
|
2018-12-04 16:22:45 +01:00
|
|
|
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
|
2018-11-28 01:35:26 +01:00
|
|
|
if(blacklistJson[message.author.id])
|
|
|
|
return blacklist(blacklistJson[message.author.id] , message)
|
|
|
|
|
2018-10-01 16:15:52 +02:00
|
|
|
let searchURL = encodeURI(search)
|
|
|
|
fetch("https://api.duckduckgo.com/?q=" + searchURL + "&format=json").then((response) => {
|
|
|
|
return response.json();
|
|
|
|
}).then((response) => {
|
|
|
|
if (response.unsafe == 1)
|
|
|
|
return message.say("No nsfw sorry...")
|
|
|
|
const ddgEmbed = new Discord.RichEmbed()
|
|
|
|
.setColor("#ff9900")
|
|
|
|
.setTitle(response.Heading)
|
|
|
|
.setURL(response.AbstractURL)
|
|
|
|
.setDescription(response.Abstract)
|
|
|
|
.addField("Topic", response.meta.topic)
|
|
|
|
.setImage(response.Image)
|
|
|
|
.setTimestamp()
|
2018-10-11 13:16:08 +02:00
|
|
|
|
2018-10-01 16:15:52 +02:00
|
|
|
message.say(ddgEmbed);
|
|
|
|
});
|
|
|
|
}};
|