summary refs log tree commit diff
path: root/src/gateway/events/Message.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/gateway/events/Message.ts')
-rw-r--r--src/gateway/events/Message.ts12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/gateway/events/Message.ts b/src/gateway/events/Message.ts
index b949f273..16e4518d 100644
--- a/src/gateway/events/Message.ts
+++ b/src/gateway/events/Message.ts
@@ -20,18 +20,18 @@ import { WebSocket, Payload, CLOSECODES, OPCODES } from "@fosscord/gateway";
 import OPCodeHandlers from "../opcodes";
 import { check } from "../opcodes/instanceOf";
 import WS from "ws";
-import { PayloadSchema } from "@fosscord/util";
+import { PayloadSchema, ErlpackType } from "@fosscord/util";
 import * as Sentry from "@sentry/node";
 import BigIntJson from "json-bigint";
 import path from "path";
 import fs from "fs/promises";
 const bigIntJson = BigIntJson({ storeAsString: true });
 
-let erlpack: { unpack: (buffer: Buffer) => Payload };
+let erlpack: ErlpackType | null = null;
 try {
-	erlpack = require("@yukikaze-bot/erlpack");
-} catch (error) {
-	/* empty */
+	erlpack = require("erlpack") as ErlpackType;
+} catch (e) {
+	// empty
 }
 
 export async function Message(this: WebSocket, buffer: WS.Data) {
@@ -52,7 +52,7 @@ export async function Message(this: WebSocket, buffer: WS.Data) {
 			}
 		}
 		data = bigIntJson.parse(buffer as string);
-	} else if (this.encoding === "etf" && buffer instanceof Buffer) {
+	} else if (this.encoding === "etf" && buffer instanceof Buffer && erlpack) {
 		try {
 			data = erlpack.unpack(buffer);
 		} catch {