diff --git a/src/websocket/discord/shard.ts b/src/websocket/discord/shard.ts index beab8e7..22e2b09 100644 --- a/src/websocket/discord/shard.ts +++ b/src/websocket/discord/shard.ts @@ -335,9 +335,9 @@ export class Shard { async close(code: number, reason: string) { clearInterval(this.heart.nodeInterval); if (!this.isOpen) { - return this.debugger?.warn(`[Shard #${this.id}] Is not open`); + return this.debugger?.warn(`[Shard #${this.id}] Is not open, reason:`, reason); } - this.debugger?.debug(`[Shard #${this.id}] Called close`); + this.debugger?.debug(`[Shard #${this.id}] Called close with reason:`, reason); this.websocket?.close(code, reason); } diff --git a/src/websocket/discord/socket/custom.ts b/src/websocket/discord/socket/custom.ts index 5c1f1cb..24f9e8d 100644 --- a/src/websocket/discord/socket/custom.ts +++ b/src/websocket/discord/socket/custom.ts @@ -234,7 +234,10 @@ export class SeyfertWebSocket { buffer.write(reason, 2); // message, close opcode this._write(buffer, 0x8); + this.socket?.end(); + + this.onclose({ code, reason }); } pong(data: string) {