diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-01-20 18:10:47 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-20 18:10:47 +1100 |
commit | 084dc0be08555891cad4c2bb984822a62ec5ec9f (patch) | |
tree | ed2ca0fafefa2224ae32761f955f63935422a97d /src/gateway/events/Message.ts | |
parent | fix: route file regex (#956) (diff) | |
download | server-084dc0be08555891cad4c2bb984822a62ec5ec9f.tar.xz |
Add ESLint (#941)
* Add eslint, switch to lint-staged for precommit * Fix all ESLint errors * Update GH workflow to check prettier and eslint
Diffstat (limited to 'src/gateway/events/Message.ts')
-rw-r--r-- | src/gateway/events/Message.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/gateway/events/Message.ts b/src/gateway/events/Message.ts index 57899a23..b949f273 100644 --- a/src/gateway/events/Message.ts +++ b/src/gateway/events/Message.ts @@ -27,14 +27,16 @@ import path from "path"; import fs from "fs/promises"; const bigIntJson = BigIntJson({ storeAsString: true }); -var erlpack: any; +let erlpack: { unpack: (buffer: Buffer) => Payload }; try { erlpack = require("@yukikaze-bot/erlpack"); -} catch (error) {} +} catch (error) { + /* empty */ +} export async function Message(this: WebSocket, buffer: WS.Data) { // TODO: compression - var data: Payload; + let data: Payload; if ( (buffer instanceof Buffer && buffer[0] === 123) || // ASCII 123 = `{`. Bad check for JSON @@ -44,9 +46,9 @@ export async function Message(this: WebSocket, buffer: WS.Data) { } else if (this.encoding === "json" && buffer instanceof Buffer) { if (this.inflate) { try { - buffer = this.inflate.process(buffer) as any; + buffer = this.inflate.process(buffer); } catch { - buffer = buffer.toString() as any; + buffer = buffer.toString(); } } data = bigIntJson.parse(buffer as string); @@ -78,7 +80,6 @@ export async function Message(this: WebSocket, buffer: WS.Data) { check.call(this, PayloadSchema, data); - // @ts-ignore const OPCodeHandler = OPCodeHandlers[data.op]; if (!OPCodeHandler) { console.error("[Gateway] Unkown opcode " + data.op); @@ -100,7 +101,7 @@ export async function Message(this: WebSocket, buffer: WS.Data) { : undefined; try { - var ret = await OPCodeHandler.call(this, data); + const ret = await OPCodeHandler.call(this, data); Sentry.withScope((scope) => { scope.setSpan(transaction); scope.setUser({ id: this.user_id }); |