get rather than request

This commit is contained in:
Jacob Janzen 2024-12-30 21:05:54 -06:00
parent 55d4967b07
commit 52e956746a

View file

@ -1,7 +1,7 @@
import { InteractionResponseType } from "discord-interactions"; import { InteractionResponseType } from "discord-interactions";
import { Message } from "./message-scheduler.js"; import { Message } from "./message-scheduler.js";
import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
import { request } from "https"; import { get } from "https";
function send(state, data) { function send(state, data) {
return state.res.send({ return state.res.send({
@ -48,26 +48,11 @@ export function blep(state) {
} }
export function catfact(state) { export function catfact(state) {
const options = { get("https://meowfacts.herokuapp.com/", (res) => {
hostname: "meowfacts.herokuapp.com", res.on("data", (d) => {
path: "/", process.stdout.write(d);
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);
}); });
}).on("error", (e) => {
console.error(e);
}); });
req.on("error", (e) => {
console.log(`https error: ${e}`);
reject(e);
});
req.end();
} }