init
This commit is contained in:
commit
f50d6ae45f
9 changed files with 854 additions and 0 deletions
23
src/index.ts
Normal file
23
src/index.ts
Normal 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
14
src/selfappReq.ts
Normal 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
0
src/types.ts
Normal file
Loading…
Add table
Add a link
Reference in a new issue