1 const fetch = require("node-fetch")
2 const google_images = require("free-google-images")
3 const common = require("./common.js")
7 params: "<keyword> [...]",
8 help: "Google Image Search",
9 func: (msg, keywords) =>
10 google_images.searchRandom(keywords.join(" "), true)
11 .then(result => msg.reply(result.image.url))
14 func: msg => fetch("https://labs.bible.org/api/?type=json&passage=random")
15 .then(res => res.json())
16 .then(data => msg.reply(`${data[0].text}\n\t${data[0].bookname} ${data[0].chapter}, ${data[0].verse}`))
19 func: (msg, term) => term.length > 0 ? fetch("https://api.dictionaryapi.dev/api/v1/entries/en_US/" + term.join(" "))
20 .then(res => res.json())
23 msg.reply(`__**${def.word}**__`
24 + (def.phonetic ? ` _${def.phonetic}_` : "")
26 + Object.entries(def.meaning).reduce((str, meaning) => str
28 + meaning[1].reduce((str, definition, i) => str + `\t${i + 1}. ${definition.definition}\n`, "")
30 + `\n[Definitions from ${def.sourceUrls.join(", ")}]`
33 .catch(_ => msg.reply("Not found"))
34 : msg.reply("You need to specify a word")
37 func: (msg, term) => term.length > 0 ? fetch("https://api.urbandictionary.com/v0/define?term=" + term.join(" "))
38 .then(res => res.json())
40 let def = common.choose(data.list)
42 msg.reply(`__**${def.word}**__\n`
43 + def.definition.replace(/\[/g,"").replace(/\]/g,"") + "\n\n"
45 + def.example.replace(/\[/g,"").replace(/\]/g,"")
48 .catch(_ => msg.reply("Not found"))
49 : msg.reply("You need to specify a word")
52 func: (msg, [targetPing]) => {
53 const target = common.getPing(msg, targetPing, true)
56 fetch("https://insult.mattbas.org/api/insult")
57 .then(res => res.text())
58 .then(data => msg.channel.send(`<@!${target}> ${data}`))
62 func: (msg, [first, last]) => {
70 fetch(`http://api.icndb.com/jokes/random?firstName=${first}&lastName=${last}`)
71 .then(res => res.json())
72 .then(data => msg.reply(data.value.joke.replace(/"/g, "\"").replace(/ /g, " ")))
76 func: msg => fetch("https://v2.jokeapi.dev/joke/Any")
77 .then(res => res.json())
78 .then(data => msg.reply(data.type == "single" ? data.joke : data.setup + "\n" + "||" + data.delivery + "||"))
81 func: msg => fetch("https://8ball.delegator.com/magic/JSON/whatever")
82 .then(res => res.json())
83 .then(data => msg.reply(data.magic.answer))
86 func: (msg, text) => fetch("https://api.emojify.net/convert", {
89 "Accept": "application/json",
90 "Content-Type": "application/json",
92 body: JSON.stringify({
94 input: text.join(" "),
95 shouldFilterEmojis: false,
98 .then(res => res.json())
99 .then(data => msg.reply(data.result))