get rather than request
This commit is contained in:
parent
55d4967b07
commit
52e956746a
1 changed files with 6 additions and 21 deletions
|
@ -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();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue