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...