summary refs log tree commit diff
path: root/src/opcodes
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-10 14:37:16 +0100
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-10 14:37:16 +0100
commit38757c60e119c29e3b501ae2f68825d7fa8cec94 (patch)
treebb9201aa0a7b7e5a962753fab832b7f3bdb51c4f /src/opcodes
parentMerge branch 'main' of https://github.com/discord-open-source/discord-gateway... (diff)
downloadserver-38757c60e119c29e3b501ae2f68825d7fa8cec94.tar.xz
update import to fosscord-server-util
Diffstat (limited to 'src/opcodes')
-rw-r--r--src/opcodes/Identify.ts19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/opcodes/Identify.ts b/src/opcodes/Identify.ts

index ebb5ca70..f0546a41 100644 --- a/src/opcodes/Identify.ts +++ b/src/opcodes/Identify.ts
@@ -1,17 +1,20 @@ import { CLOSECODES, Payload } from "../util/Constants"; -import Config from "../util/Config"; import WebSocket from "../util/WebSocket"; -import { checkToken, IdentifySchema } from "discord-server-util"; -import { check } from "./instanceOf"; +import { checkToken, IdentifySchema } from "fosscord-server-util"; +import { setupListener } from "../listener/listener"; +import { instanceOf } from "lambert-server"; export async function onIdentify(this: WebSocket, data: Payload) { - clearTimeout(this.readyTimeout); - if (check.call(this, IdentifySchema, data.d)) return; + try { + clearTimeout(this.readyTimeout); + instanceOf(IdentifySchema, data.d); - const identify: IdentifySchema = data.d; + const identify: IdentifySchema = data.d; - try { - var { id } = await checkToken(identify.token); + var decoded = await checkToken(identify.token); + this.userid = decoded.id; + + await setupListener.call(this); } catch (error) { return this.close(CLOSECODES.Authentication_failed); }