This commit is contained in:
nin0 2025-05-11 09:33:31 -04:00
commit f50d6ae45f
Signed by: nin0
SSH key fingerprint: SHA256:NOoDnFVvZNFvqfXCIhzr6oCTDImZAbTTuyAysZ8Ufk8
9 changed files with 854 additions and 0 deletions

23
src/index.ts Normal file
View file

@ -0,0 +1,23 @@
import { AllIntents, Client } from "oceanic.js";
import { selfappReq } from "./selfappReq";
import { setupJoinRequestHandler } from "./joinRequestHandler";
export const client = new Client({
auth: `Bot ${process.env.BOT_TOKEN}`,
gateway: {
intents: AllIntents,
compress: false
}
});
client.on("ready", async () => {
console.log(`Logged in as ${client.user.tag}`);
console.log("Checking user token");
const selfappInfo = await selfappReq("/users/@me", "GET");
if (!selfappInfo.username) console.error("Can't use selfapp");
else console.log("Can use selfapp");
setupJoinRequestHandler(client.shards.first()!);
});
client.connect();

14
src/selfappReq.ts Normal file
View file

@ -0,0 +1,14 @@
export async function selfappReq(
path: string,
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE",
data?: object
) {
return await fetch("https://discord.com/api/v9" + path, {
method,
headers: {
Authorization: process.env.USER_TOKEN!,
...(data ? { "Content-Type": "application/json" } : {})
},
body: data ? JSON.stringify(data || {}) : null
}).then((e) => e.json());
}

0
src/types.ts Normal file
View file