From 7892e62604da55fd9dc410be66287500902064c2 Mon Sep 17 00:00:00 2001 From: Hyper-Coder Date: Wed, 24 Aug 2016 12:16:22 -0400 Subject: [PATCH 1/2] Added Client.uptime (#533) * Added Client.uptime * Added Client.uptime * Update Client.js --- src/client/Client.js | 13 +++++++++++++ src/client/websocket/packets/handlers/Ready.js | 1 + 2 files changed, 14 insertions(+) diff --git a/src/client/Client.js b/src/client/Client.js index dfbd5c37b..c44df5453 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -94,6 +94,11 @@ class Client extends EventEmitter { * @type {?String} */ this.password = null; + /** + * The time in milliseconds the Client connected + * @type {?Number} + */ + this.readyTime = null; } /** @@ -124,6 +129,14 @@ class Client extends EventEmitter { return this.rest.methods.loginToken(email); } + /** + * The uptime for the logged in Client + * @type {?Number} + */ + get uptime() { + return this.readyTime ? Date.now() - this.readyTime : null; + } + } module.exports = Client; diff --git a/src/client/websocket/packets/handlers/Ready.js b/src/client/websocket/packets/handlers/Ready.js index 475d9b6eb..217127c77 100644 --- a/src/client/websocket/packets/handlers/Ready.js +++ b/src/client/websocket/packets/handlers/Ready.js @@ -11,6 +11,7 @@ class ReadyHandler extends AbstractHandler { const clientUser = new ClientUser(client, data.user); client.user = clientUser; + client.readyTime = Date.now(); client.users.set(clientUser.id, clientUser); for (const guild of data.guilds) { client.dataManager.newGuild(guild); From cdb74a75f2e0853a86595ab659447f913867f675 Mon Sep 17 00:00:00 2001 From: LewisHogan Date: Wed, 24 Aug 2016 23:38:07 +0100 Subject: [PATCH 2/2] Indev rewrite - Changed GuildChannel type (#536) * Altered GuildChannel.type to return a string containing either "text", "voice" or the id of the channel type. * Fixed typo * Altered code to pass ESLint test (Functionality Unchanged). * Third times the charm. --- src/structures/GuildChannel.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index b8f6b196a..96ff2be4e 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -33,9 +33,11 @@ class GuildChannel extends Channel { super.setup(data); /** * The type of the Guild Channel - * @type {Number} + * @type {String} */ - this.type = data.type; + if (data.type === 0) this.type = 'text'; + else if (data.type === 2) this.type = 'voice'; + else this.type = data.type.toString(); /** * The topic of the Guild Channel, if there is one. * @type {?String}