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);
+ }
+}
|