Skip to content

Commit

Permalink
fix(status): Fix startup time. Add state
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Crespi committed Mar 25, 2020
1 parent f78c590 commit e3e390a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ export class IMClient extends Client {
guildCreateTimeout: 60000
});

this.startedAt = moment();
this.stats = {
wsEvents: 0,
wsWarnings: 0,
Expand Down Expand Up @@ -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 };
Expand Down
12 changes: 9 additions & 3 deletions src/framework/services/RabbitMq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e3e390a

Please sign in to comment.