From 2c1f101ef5f0813882ca4b7a8960744aa203769f Mon Sep 17 00:00:00 2001 From: Roman Khabarov Date: Wed, 29 May 2024 00:01:12 +0200 Subject: [PATCH] fix --- .../stat-reporter/nestcord-stat-reporter.service.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/stat-reporter/nestcord-stat-reporter.service.ts b/packages/stat-reporter/nestcord-stat-reporter.service.ts index 414bd7d..d6afa5e 100644 --- a/packages/stat-reporter/nestcord-stat-reporter.service.ts +++ b/packages/stat-reporter/nestcord-stat-reporter.service.ts @@ -19,9 +19,9 @@ export class NestCordStatReporterService implements OnModuleInit { onModuleInit() { this.client.on('ready', () => { - const isFirstShard = this.client.shard && this.client.shard.ids?.[0] === 0; + const isFirstShard = (this.client.shard && this.client.shard.ids?.[0] === 0) || !this.client.shard; const isProduction = !this.options.development; - + if (isFirstShard && isProduction) { this.setupCronJobs(); } @@ -42,8 +42,10 @@ export class NestCordStatReporterService implements OnModuleInit { let serverCount: number; const shardCount = this.client.shard?.count; if (this.client.shard) { - const totalServersOnAllShards = await this.client.shard.fetchClientValues('guilds.cache.size') as number[] - serverCount = totalServersOnAllShards.reduce((acc, guildCount) => acc + guildCount, 0) || this.client.application.approximateGuildCount; + const totalServersOnAllShards = (await this.client.shard.fetchClientValues('guilds.cache.size')) as number[]; + serverCount = + totalServersOnAllShards.reduce((acc, guildCount) => acc + guildCount, 0) || + this.client.application.approximateGuildCount; } else { serverCount = this.client.guilds.cache.size; }