From e3e3c73056b1980ee214d7047aa2d104c515f737 Mon Sep 17 00:00:00 2001 From: Helloyunho Date: Thu, 9 Nov 2023 14:29:01 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=EF=B8=8F=20fix:=20closing=20websoc?= =?UTF-8?q?ket=20requires=20reason?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/client.ts | 6 +++--- src/gateway/mod.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/client.ts b/src/client/client.ts index 5928685c..4cbccb24 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -392,9 +392,9 @@ export class Client extends HarmonyEventEmitter { /** Attempt to Close current Gateway connection and Resume */ async reconnect(): Promise { - this.gateway.closeGateway() - this.gateway.initWebsocket() - return this.waitFor('ready', () => true).then(() => this) + await this.gateway.reconnect() + await this.waitFor('resumed') + return this } /** Add a new Collector */ diff --git a/src/gateway/mod.ts b/src/gateway/mod.ts index 42613714..89b22c72 100644 --- a/src/gateway/mod.ts +++ b/src/gateway/mod.ts @@ -465,7 +465,7 @@ export class Gateway extends HarmonyEventEmitter { await this.cache.delete(`seq_${this.shards?.join('-') ?? '0'}`) } - this.closeGateway(3999) + this.closeGateway(RECONNECT_CODE, 'Reconnecting...') this.initWebsocket() } @@ -494,7 +494,7 @@ export class Gateway extends HarmonyEventEmitter { reason !== undefined && reason !== '' ? ` and reason ${reason}` : '' }` ) - return this.websocket?.close(code, reason) + this.websocket?.close(code, reason) } // Alias for backward compat, since event@2.0.0 removed close again...