]> git.lizzy.rs Git - furrybot-discord.git/commitdiff
Add joke API that is actually funny
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 6 Mar 2022 14:47:41 +0000 (15:47 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 6 Mar 2022 14:47:41 +0000 (15:47 +0100)
http.js

diff --git a/http.js b/http.js
index 36f2555bf59134ec13817f426fcf2fe7355a8eb6..4572419c000b722a502d173dbe3e2736a0b839b1 100644 (file)
--- a/http.js
+++ b/http.js
@@ -58,7 +58,7 @@ module.exports = {
                                        .then(data => msg.channel.send(`<@!${target}> ${data}`))
                }
        },
-       joke: {
+       chucknorris: {
                func: (msg, [first, last]) => {
                        if (!first) {
                                first = "Chuck"
@@ -72,6 +72,11 @@ module.exports = {
                                .then(data => msg.reply(data.value.joke.replace(/&quot;/g, "\"").replace(/  /g, " ")))
                }
        },
+       joke: {
+               func: msg => fetch("https://v2.jokeapi.dev/joke/Any")
+                       .then(res => res.json())
+                       .then(data => msg.reply(data.type == "single" ? data.joke : data.setup + "\n" + "||" + data.delivery + "||"))
+       },
        "8ball": {
                func: msg => fetch("https://8ball.delegator.com/magic/JSON/whatever")
                        .then(res => res.json())