From e3e390a6e339f51412ba12f6aa3f2cb7ffafac19 Mon Sep 17 00:00:00 2001 From: Marco Crespi Date: Wed, 25 Mar 2020 09:40:35 +0100 Subject: [PATCH] fix(status): Fix startup time. Add state --- src/client.ts | 2 +- src/framework/services/RabbitMq.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/client.ts b/src/client.ts index 893608e1..f5a7d90d 100644 --- a/src/client.ts +++ b/src/client.ts @@ -162,7 +162,6 @@ export class IMClient extends Client { guildCreateTimeout: 60000 }); - this.startedAt = moment(); this.stats = { wsEvents: 0, wsWarnings: 0, @@ -264,6 +263,7 @@ export class IMClient extends Client { await Promise.all(Object.values(this.service).map((s) => s.onClientReady())); this.hasStarted = true; + this.startedAt = moment(); const set = await this.db.getBotSettings(this.user.id); this.settings = set ? set.value : { ...botDefaultSettings }; diff --git a/src/framework/services/RabbitMq.ts b/src/framework/services/RabbitMq.ts index 77ae2e31..b1a4e779 100644 --- a/src/framework/services/RabbitMq.ts +++ b/src/framework/services/RabbitMq.ts @@ -231,11 +231,17 @@ export class RabbitMqService extends IMService { await this.sendToManager({ id: 'status', cmd: ShardCommand.STATUS, - connected: this.client.gatewayConnected, + state: this.waitingForTicket + ? 'waiting' + : !this.client.hasStarted + ? 'init' + : !!this.startTicket + ? 'starting' + : 'running', + startedAt: this.client.startedAt.toISOString(), + gateway: this.client.gatewayConnected, guilds: this.client.guilds.size, error: err ? err.message : null, - starting: !!this.startTicket, - waitingToStart: this.waitingForTicket, tracking: { pendingGuilds: this.client.tracking.pendingGuilds.size, initialPendingGuilds: this.client.tracking.initialPendingGuilds