zL1ghT_

MessageEvent err

Apr 11th, 2021
75
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Payload.ts
  2.  
  3. export interface Payload {
  4.     op: OP;
  5.     d?: string;
  6.     s?: number;
  7.     t?: string;
  8. }
  9.  
  10. // WebSocketManager.ts
  11.  
  12. import { Payload, OP } from '../models/Payload.ts'
  13.  
  14. export default class WebSocketManager {
  15.     private _ws!: WebSocket;
  16.  
  17.     connect(token: string) {
  18.         this._ws = new WebSocket("wss://gateway.discord.gg/?v=8&encoding=json");
  19.  
  20.         this._ws.onmessage = this._message;
  21.     }
  22.  
  23.     close() {
  24.         console.log("closing the socket...");
  25.         this._ws.close(1);
  26.     }
  27.  
  28.     private _message({ data }: MessageEvent<Payload>) {
  29.         console.log(data.d, data.t, data.s, data.op); // <--- HERE ERROR
  30.         // undefined undefined undefined undefined
  31.     }
  32. }
RAW Paste Data