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(" "))
11 .then(result => msg.reply(result.image.url))
15 func: msg => fetch("https://labs.bible.org/api/?type=json&passage=random")
16 .then(res => res.json())
17 .then(data => msg.reply(`${data[0].text} [${data[0].bookname} ${data[0].chapter}, ${data[0].verse}]`))
20 func: (msg, [word]) => word ? fetch("https://api.dictionaryapi.dev/api/v1/entries/en_US/" + word)
21 .then(res => res.json())
24 msg.reply(`__**${def.word}**__`
25 + (def.phonetic ? ` _${def.phonetic}_` : "")
27 + Object.entries(def.meaning).reduce((str, meaning) => str
29 + meaning[1].reduce((str, definition, i) => str + `\t${i + 1}. ${definition.definition}\n`, "")
31 + `\n[Definitions from ${def.sourceUrls.join(", ")}]`
34 .catch(_ => msg.reply("Not found"))
35 : msg.reply("You need to specify a word")
38 func: (msg, [word]) => word ? fetch("https://api.urbandictionary.com/v0/define?term=" + word)
39 .then(res => res.json())
41 let def = common.choose(data.list)
43 msg.reply(`__**${def.word}**__\n`
44 + def.definition.replace(/\[/g,"").replace(/\]/g,"") + "\n\n"
46 + def.example.replace(/\[/g,"").replace(/\]/g,"")
49 .catch(_ => msg.reply("Not found"))
50 : msg.reply("You need to specify a word")
53 func: (msg, [targetPing]) => {
54 const target = common.getPing(msg, targetPing, true)
57 fetch("https://insult.mattbas.org/api/insult")
58 .then(res => res.text())
59 .then(data => msg.channel.send(`<@!${target}> ${data}`))
63 func: (msg, [first, last]) => {
71 fetch(`http://api.icndb.com/jokes/random?firstName=${first}&lastName=${last}`)
72 .then(res => res.json())
73 .then(data => msg.reply(data.value.joke.replace(/"/g, "\"").replace(/ /g, " ")))
77 func: msg => fetch("https://8ball.delegator.com/magic/JSON/whatever")
78 .then(res => res.json())
79 .then(data => msg.reply(data.magic.answer))