diff --git a/src/Server.ts b/src/Server.ts
index 302aea81..df5ec905 100644
--- a/src/Server.ts
+++ b/src/Server.ts
@@ -1,3 +1,6 @@
+import "missing-native-js-functions";
+import dotenv from "dotenv";
+dotenv.config();
import { db } from "fosscord-server-util";
import { Server as WebSocketServer } from "ws";
import { Connection } from "./events/Connection";
@@ -19,7 +22,8 @@ export class Server {
// @ts-ignore
await (db as Promise<Connection>);
await this.setupSchema();
+ console.log("[DB] connected");
await Config.init();
- console.log("listening");
+ console.log("[Gateway] online");
}
}
diff --git a/src/index.ts b/src/index.ts
index e34ae0d3..2fe360e2 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,6 +1,5 @@
process.on("uncaughtException", console.error);
process.on("unhandledRejection", console.error);
-setTimeout(() => {}, 100000000);
import { Server } from "./Server";
import { config } from "dotenv";
diff --git a/src/listener/listener.ts b/src/listener/listener.ts
index 24b05765..b6ae0ac6 100644
--- a/src/listener/listener.ts
+++ b/src/listener/listener.ts
@@ -8,11 +8,11 @@ import WebSocket from "../util/WebSocket";
// ? How to resubscribe MongooseCache for new dm channel events? Maybe directly send them to the user_id regardless of the channel_id? -> max overhead of creating 10 events in database for dm user group. Or a new field in event -> recipient_ids?
export async function setupListener(this: WebSocket) {
- const user = await UserModel.findOne({ id: this.userid }).exec();
+ const user = await UserModel.findOne({ id: this.user_id }).exec();
const eventStream = new MongooseCache(
db.collection("events"),
- [{ $match: { $or: [{ guild_id: { $in: user.guilds } }, { user_id: this.userid }] } }],
+ [{ $match: { $or: [{ guild_id: { $in: user.guilds } }, { user_id: this.user_id }] } }],
{ onlyEvents: true }
);
await eventStream.init();
@@ -27,7 +27,7 @@ export async function dispatch(this: WebSocket, document: Event) {
if (document.guild_id) {
if (!this.intents.has("GUILDS")) return;
const channel_id = document.channel_id || document.data?.channel_id;
- permission = await getPermission(this.userid, document.guild_id, channel_id);
+ permission = await getPermission(this.user_id, document.guild_id, channel_id);
}
console.log("event", document);
diff --git a/src/opcodes/Identify.ts b/src/opcodes/Identify.ts
index f62f66b0..f2542bc8 100644
--- a/src/opcodes/Identify.ts
+++ b/src/opcodes/Identify.ts
@@ -14,7 +14,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
const identify: IdentifySchema = data.d;
var decoded = await checkToken(identify.token);
- this.userid = decoded.id;
+ this.user_id = decoded.id;
this.intents = new Intents(identify.intents);
await setupListener.call(this);
diff --git a/src/util/WebSocket.ts b/src/util/WebSocket.ts
index 10b8348f..5d107d9c 100644
--- a/src/util/WebSocket.ts
+++ b/src/util/WebSocket.ts
@@ -3,7 +3,7 @@ import WS, { Server, Data } from "ws";
interface WebSocket extends WS {
version: number;
- userid: bigint;
+ user_id: bigint;
encoding: "etf" | "json";
compress?: "zlib-stream";
heartbeatTimeout: NodeJS.Timeout;
|