summary refs log tree commit diff
path: root/src/opcodes/Identify.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-06 17:08:18 +0100
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-06 17:08:18 +0100
commit4eba7f5068e86ac988547043abb6d0e669748468 (patch)
treef015c31fcdc7970a4201f2801ad1f223322d5ba8 /src/opcodes/Identify.ts
parent:sparkles: Base Server (diff)
downloadserver-4eba7f5068e86ac988547043abb6d0e669748468.tar.xz
:sparkles: opcodes
Diffstat (limited to 'src/opcodes/Identify.ts')
-rw-r--r--src/opcodes/Identify.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/opcodes/Identify.ts b/src/opcodes/Identify.ts
new file mode 100644

index 00000000..ebb5ca70 --- /dev/null +++ b/src/opcodes/Identify.ts
@@ -0,0 +1,18 @@ +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"; + +export async function onIdentify(this: WebSocket, data: Payload) { + clearTimeout(this.readyTimeout); + if (check.call(this, IdentifySchema, data.d)) return; + + const identify: IdentifySchema = data.d; + + try { + var { id } = await checkToken(identify.token); + } catch (error) { + return this.close(CLOSECODES.Authentication_failed); + } +}