connect() {
        this.ws = new WebSocket('wss://gateway.discord.gg/?v=6&encoding=json');
        this.guildCount = 0;
        this.bootTime = new Date();
        this.seq = 0;
        this.sessionID = null;

        this.ws.removeAllListeners();

        this.ws.once('open', () => this.identify());
        this.ws.on('error', (err) => { this.emit('error', 'Websocket error', err); });
        this.ws.on('message', (data) => this.onWS(data));


        this.ws.on('close', (code) => {
            this.emit('warn', 'Websocket closed', code);

            if (code === 1000) {
                clearInterval(this.heartbeatInterval);

                this.resume();
            } else {
                this.disconnect();
                setTimeout(() => {
                    this.connect();
                }, 5000);
            }
        });
    }
/**
     * Connect to the websocket
     *
     * @memberof Client
     */
Connect to the websocket
@memberof Client
Connect to the websocket @memberof Client
connect() {
        this.ws = new WebSocket('wss://gateway.discord.gg/?v=6&encoding=json');
        this.guildCount = 0;
        this.bootTime = new Date();
        this.seq = 0;
        this.sessionID = null;
        this.ws.removeAllListeners();
        this.ws.once('open', () => this.identify());
        this.ws.on('error', (err) => { this.emit('error', 'Websocket error', err); });
        this.ws.on('message', (data) => this.onWS(data));
        this.ws.on('close', (code) => {
            this.emit('warn', 'Websocket closed', code);
            if (code === 1000) {
                clearInterval(this.heartbeatInterval);
                this.resume();
            } else {
                this.disconnect();
                setTimeout(() => {
                    this.connect();
                }, 5000);
            }
        });
    }
connect ( ) { this . ws = new WebSocket ( 'wss://gateway.discord.gg/?v=6&encoding=json' ) ; this . guildCount = 0 ; this . bootTime = new Date ( ) ; this . seq = 0 ; this . sessionID = null ; this . ws . removeAllListeners ( ) ; this . ws . once ( 'open' , ( ) => this . identify ( ) ) ; this . ws . on ( 'error' , ( err ) => { this . emit ( 'error' , 'Websocket error' , err ) ; } ) ; this . ws . on ( 'message' , ( data ) => this . onWS ( data ) ) ; this . ws . on ( 'close' , ( code ) => { this . emit ( 'warn' , 'Websocket closed' , code ) ; if ( code === 1000 ) { clearInterval ( this . heartbeatInterval ) ; this . resume ( ) ; } else { this . disconnect ( ) ; setTimeout ( ( ) => { this . connect ( ) ; } , 5000 ) ; } } ) ; }
Connect to the websocket
 @memberof Client
Connect to the websocket @memberof Client