Can now search DuckDuckgo
This commit is contained in:
parent
47518307ca
commit
acde60ee46
1 changed files with 40 additions and 0 deletions
40
commands/utility/info.js
Normal file
40
commands/utility/info.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
const { Command } = require('discord.js-commando');
|
||||||
|
const Discord = require('discord.js');
|
||||||
|
const fetch = require('node-fetch')
|
||||||
|
module.exports = class RandoCatCommand extends Command {
|
||||||
|
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 }) {
|
||||||
|
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()
|
||||||
|
.setFooter("Provided to you by DuckDuckgo", "https://i.imgur.com/POGt26Z.png")
|
||||||
|
|
||||||
|
message.say(ddgEmbed);
|
||||||
|
});
|
||||||
|
}};
|
Loading…
Reference in a new issue