diff options
author | Jacob Janzen <jacob.a.s.janzen@gmail.com> | 2024-12-30 20:58:25 -0600 |
---|---|---|
committer | Jacob Janzen <jacob.a.s.janzen@gmail.com> | 2024-12-30 20:58:25 -0600 |
commit | f97d1e32bf80f4d9ce2339f526a1e7722387dacc (patch) | |
tree | e82cdf279b4114f7052bbabdf4c1a9e5ea83bc5c /command_impls.js | |
parent | 04b0fa8855b62fac8677300c8ced95852358e44b (diff) |
try https for request
Diffstat (limited to 'command_impls.js')
-rw-r--r-- | command_impls.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/command_impls.js b/command_impls.js index 92bc544..f6508fb 100644 --- a/command_impls.js +++ b/command_impls.js @@ -1,6 +1,7 @@ import { InteractionResponseType } from "discord-interactions"; import { Message } from "./message-scheduler.js"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js"; +import { request } from "https"; function send(state, data) { return state.res.send({ @@ -45,3 +46,28 @@ Here are the available commands and their descriptions: export function blep(state) { return send(state, { content: "≽^•𐃷•^≼" }); } + +export function catfact(state) { + const options = { + hostname: "meowfacts.herokuapp.com", + path: "/", + port: 443, + method: "GET", + }; + + let body = []; + + const req = request(options, (res) => { + res.on("data", (chunk) => body.push(chunk)); + res.on("end", () => { + const data = Buffer.concat(body).toString(); + resolve(data); + console.log(data); + }); + }); + req.on("error", (e) => { + console.log(`https error: ${e}`); + reject(e); + }); + req.end(); +} |