diff --git a/src/opcodes/Identify.ts b/src/opcodes/Identify.ts index 0f0ca470..f31eebfe 100644 --- a/src/opcodes/Identify.ts +++ b/src/opcodes/Identify.ts @@ -13,7 +13,6 @@ import { EVENTEnum, } from "@fosscord/server-util"; import { setupListener } from "../listener/listener"; -import { instanceOf } from "lambert-server"; import { IdentifySchema } from "../schema/Identify"; import { Send } from "../util/Send"; import experiments from "./experiments.json"; @@ -25,7 +24,7 @@ import { check } from "./instanceOf"; export async function onIdentify(this: WebSocket, data: Payload) { clearTimeout(this.readyTimeout); - if (!check.call(this, IdentifySchema, data.d)) return; + check.call(this, IdentifySchema, data.d); const identify: IdentifySchema = data.d; diff --git a/src/opcodes/instanceOf.ts b/src/opcodes/instanceOf.ts index 4a34477f..7dcc95a2 100644 --- a/src/opcodes/instanceOf.ts +++ b/src/opcodes/instanceOf.ts @@ -4,11 +4,15 @@ import WebSocket from "../util/WebSocket"; export function check(this: WebSocket, schema: any, data: any) { try { - if (instanceOf(schema, data) !== true) throw "invalid"; + const error = instanceOf(schema, data); + if (error !== true) { + throw error; + } + return true; } catch (error) { console.error(error); // invalid payload this.close(CLOSECODES.Decode_error); - return false; + throw error; } }