summary refs log tree commit diff
path: root/src/gateway/events/Connection.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/gateway/events/Connection.ts')
-rw-r--r--src/gateway/events/Connection.ts22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/gateway/events/Connection.ts b/src/gateway/events/Connection.ts
index 82081266..5ba68ef7 100644
--- a/src/gateway/events/Connection.ts
+++ b/src/gateway/events/Connection.ts
@@ -27,12 +27,13 @@ import { Close } from "./Close";
 import { Message } from "./Message";
 import { Deflate, Inflate } from "fast-zlib";
 import { URL } from "url";
-import { Config } from "@fosscord/util";
-let erlpack: unknown;
+import { Config, ErlpackType } from "@fosscord/util";
+
+let erlpack: ErlpackType | null = null;
 try {
-	erlpack = require("@yukikaze-bot/erlpack");
-} catch (error) {
-	/* empty */
+	erlpack = require("erlpack") as ErlpackType;
+} catch (e) {
+	// empty
 }
 
 // TODO: check rate limit
@@ -84,14 +85,11 @@ export async function Connection(
 		const { searchParams } = new URL(`http://localhost${request.url}`);
 		// @ts-ignore
 		socket.encoding = searchParams.get("encoding") || "json";
-		if (!["json", "etf"].includes(socket.encoding)) {
-			if (socket.encoding === "etf" && erlpack) {
-				throw new Error(
-					"Erlpack is not installed: 'npm i @yukikaze-bot/erlpack'",
-				);
-			}
+		if (!["json", "etf"].includes(socket.encoding))
 			return socket.close(CLOSECODES.Decode_error);
-		}
+
+		if (socket.encoding === "etf" && erlpack)
+			throw new Error("Erlpack is not installed: 'npm i erlpack'");
 
 		socket.version = Number(searchParams.get("version")) || 8;
 		if (socket.version != 8)