From 67da457c0a8a08188c0fe3a49e2b7ed4b514ba5f Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Sun, 5 May 2019 13:44:34 +0200 Subject: [PATCH] fix/docs(Client): type status and do not throw an error if accessed before login --- src/client/Client.js | 4 ++-- src/client/websocket/WebSocketConnection.js | 2 +- src/util/Constants.js | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/client/Client.js b/src/client/Client.js index c0b56f66d..e8a422e68 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -186,11 +186,11 @@ class Client extends EventEmitter { /** * Current status of the client's connection to Discord - * @type {?number} + * @type {Status} * @readonly */ get status() { - return this.ws.connection.status; + return this.ws.connection ? this.ws.connection.status : Constants.Status.IDLE; } /** diff --git a/src/client/websocket/WebSocketConnection.js b/src/client/websocket/WebSocketConnection.js index 1b458e5a1..2937f62c1 100644 --- a/src/client/websocket/WebSocketConnection.js +++ b/src/client/websocket/WebSocketConnection.js @@ -59,7 +59,7 @@ class WebSocketConnection extends EventEmitter { /** * The current status of the client - * @type {number} + * @type {Status} */ this.status = Constants.Status.IDLE; diff --git a/src/util/Constants.js b/src/util/Constants.js index 601c26a95..7a8e13443 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -242,12 +242,12 @@ const Endpoints = exports.Endpoints = { /** * The current status of the client. Here are the available statuses: - * * READY - * * CONNECTING - * * RECONNECTING - * * IDLE - * * NEARLY - * * DISCONNECTED + * * READY: 0 + * * CONNECTING: 1 + * * RECONNECTING: 2 + * * IDLE: 3 + * * NEARLY: 4 + * * DISCONNECTED: 5 * @typedef {number} Status */ exports.Status = {