diff options
author | Jacob Janzen <jacob.a.s.janzen@gmail.com> | 2024-12-30 21:05:54 -0600 |
---|---|---|
committer | Jacob Janzen <jacob.a.s.janzen@gmail.com> | 2024-12-30 21:05:54 -0600 |
commit | 52e956746ae086878faa9771c467b3e4db3b832c (patch) | |
tree | 52ebd93bcbebed81a6f13105db0869b11a83faea /command_impls.js | |
parent | 55d4967b0705390cb08d152a30f44e8722e835a0 (diff) |
get rather than request
Diffstat (limited to 'command_impls.js')
-rw-r--r-- | command_impls.js | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/command_impls.js b/command_impls.js index f6508fb..33f1b6c 100644 --- a/command_impls.js +++ b/command_impls.js @@ -1,7 +1,7 @@ import { InteractionResponseType } from "discord-interactions"; import { Message } from "./message-scheduler.js"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js"; -import { request } from "https"; +import { get } from "https"; function send(state, data) { return state.res.send({ @@ -48,26 +48,11 @@ export function blep(state) { } 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); + get("https://meowfacts.herokuapp.com/", (res) => { + res.on("data", (d) => { + process.stdout.write(d); }); + }).on("error", (e) => { + console.error(e); }); - req.on("error", (e) => { - console.log(`https error: ${e}`); - reject(e); - }); - req.end(); } |