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}`))
65 furrybot.commands.joke = {
66 func = function(name, first, last)
73 furrybot.json_http_request("http://api.icndb.com/jokes/random?firstName=" .. first .. "&lastName=" .. last, name, function(data)
74 local joke = data.value.joke:gsub(""", "\""):gsub(" ", " ")
75 furrybot.send(joke, furrybot.colors.fun)
80 furrybot.commands["8ball"] = {
82 furrybot.json_http_request("https://8ball.delegator.com/magic/JSON/anything", name, function(data)
83 furrybot.ping_message(name, data.magic.answer, furrybot.colors.fun)
88 return function(_http, _env, _storage)
89 http, env, storage = _http, _env, _storage