diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-02-01 13:00:04 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-01 13:00:04 +1100 |
commit | da2086696784f4d4d82eb853630e4d94662661dd (patch) | |
tree | c8bf2c3b587844f7993d76db555d70f2dbfa0d2b /src/gateway/events/Message.ts | |
parent | use print instead of console.log in client cache so it doesn't output weirdness (diff) | |
download | server-da2086696784f4d4d82eb853630e4d94662661dd.tar.xz |
Use erlpack instead of @yukikaze-bot/erlpack (#968)
Diffstat (limited to 'src/gateway/events/Message.ts')
-rw-r--r-- | src/gateway/events/Message.ts | 12 |
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 { |