disconnect(options = {}, error) {
        if(!this.ws) {
            return;
        }
        if(this.heartbeatInterval) {
            clearInterval(this.heartbeatInterval);
            this.heartbeatInterval = null;
        }

        this.ws.onclose = undefined;
        try {
            if(options.reconnect && this.sessionID) {
                this.ws.terminate();
            } else {
                this.ws.close(1000);
            }
        } catch(err) {
            /**
            * Fired when the shard encounters an error
            * @event Client#error
            * @prop {Error} err The error
            * @prop {Number} id The ID of the shard
            */
            this.emit("error", err, this.id);
        }

        /**
        * Fired when the shard disconnects
        * @event Shard#disconnect
        * @prop {Error?} err The error, if any
        */
        super.emit("disconnect", error || null);
        this.ws = null;

        this.reset();
        if(options.reconnect === "auto" && this.client.options.autoreconnect) {
            /**
            * Fired when stuff happens and gives more info
            * @event Client#debug
            * @prop {String} message The debug message
            * @prop {Number} id The ID of the shard
            */
            this.emit("debug", `Queueing reconnect in ${this.reconnectInterval}ms | Attempt ${this.connectAttempts}`, this.id);
            setTimeout(() => {
                this.client.shards.connect(this);
            }, this.reconnectInterval);
            this.reconnectInterval = Math.min(Math.round(this.reconnectInterval * (Math.random() * 2 + 1)), 30000);
        } else if(!options.reconnect) {
            this.hardReset();
        }
    }
/**
    * Disconnects the shard
    * @arg {Object?} [options] Shard disconnect options
    * @arg {String | Boolean} [options.reconnect] false means destroy everything, true means you want to reconnect in the future, "auto" will autoreconnect
    */
Disconnects the shard
@arg {Object?} [options] Shard disconnect options
@arg {String | Boolean} [options.reconnect] false means destroy everything, true means you want to reconnect in the future, "auto" will autoreconnect
Disconnects the shard @arg { Object? } [ options ] Shard disconnect options @arg { String | Boolean } [ options . reconnect ] false means destroy everything true means you want to reconnect in the future " auto " will autoreconnect
disconnect(options = {}, error) {
        if(!this.ws) {
            return;
        }
        if(this.heartbeatInterval) {
            clearInterval(this.heartbeatInterval);
            this.heartbeatInterval = null;
        }
        this.ws.onclose = undefined;
        try {
            if(options.reconnect && this.sessionID) {
                this.ws.terminate();
            } else {
                this.ws.close(1000);
            }
        } catch(err) {
            this.emit("error", err, this.id);
        }
        super.emit("disconnect", error || null);
        this.ws = null;
        this.reset();
        if(options.reconnect === "auto" && this.client.options.autoreconnect) {
            this.emit("debug", `Queueing reconnect in ${this.reconnectInterval}ms | Attempt ${this.connectAttempts}`, this.id);
            setTimeout(() => {
                this.client.shards.connect(this);
            }, this.reconnectInterval);
            this.reconnectInterval = Math.min(Math.round(this.reconnectInterval * (Math.random() * 2 + 1)), 30000);
        } else if(!options.reconnect) {
            this.hardReset();
        }
    }
disconnect ( options = { } , error ) { if ( ! this . ws ) { return ; } if ( this . heartbeatInterval ) { clearInterval ( this . heartbeatInterval ) ; this . heartbeatInterval = null ; } this . ws . onclose = undefined ; try { if ( options . reconnect && this . sessionID ) { this . ws . terminate ( ) ; } else { this . ws . close ( 1000 ) ; } } catch ( err ) { this . emit ( "error" , err , this . id ) ; } super . emit ( "disconnect" , error || null ) ; this . ws = null ; this . reset ( ) ; if ( options . reconnect === "auto" && this . client . options . autoreconnect ) { this . emit ( "debug" , ` ${ this . reconnectInterval } ${ this . connectAttempts } ` , this . id ) ; setTimeout ( ( ) => { this . client . shards . connect ( this ) ; } , this . reconnectInterval ) ; this . reconnectInterval = Math . min ( Math . round ( this . reconnectInterval * ( Math . random ( ) * 2 + 1 ) ) , 30000 ) ; } else if ( ! options . reconnect ) { this . hardReset ( ) ; } }
Disconnects the shard
 @arg {Object?}
Disconnects the shard @arg { Object? }
/**
            * Fired when the shard encounters an error
            * @event Client#error
            * @prop {Error} err The error
            * @prop {Number} id The ID of the shard
            */ /**
        * Fired when the shard disconnects
        * @event Shard#disconnect
        * @prop {Error?} err The error, if any
        */ /**
            * Fired when stuff happens and gives more info
            * @event Client#debug
            * @prop {String} message The debug message
            * @prop {Number} id The ID of the shard
            */