From 264d6b49fbf2000b9112d6b27fd7faac0f3013bc Mon Sep 17 00:00:00 2001 From: ayntee Date: Fri, 25 Dec 2020 20:18:35 +0400 Subject: [PATCH] refactor: destructure code and reason from event --- src/gateway/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gateway/index.ts b/src/gateway/index.ts index 85beb62..0477174 100644 --- a/src/gateway/index.ts +++ b/src/gateway/index.ts @@ -177,12 +177,12 @@ export class Gateway extends EventEmitter { } } - private async onclose(event: CloseEvent): Promise { - if (event.reason === RECONNECT_REASON) return - this.emit('close', event.code, event.reason) - this.debug(`Connection Closed with code: ${event.code}`) + private async onclose({ reason, code }: CloseEvent): Promise { + if (reason === RECONNECT_REASON) return + this.emit('close', code, reason) + this.debug(`Connection Closed with code: ${code}`) - switch (event.code) { + switch (code) { case GatewayCloseCodes.UNKNOWN_ERROR: this.debug('API has encountered Unknown Error. Reconnecting...') // eslint-disable-next-line @typescript-eslint/no-floating-promises