From fa1ce837c17571456a5dce2b188f52f86266ba71 Mon Sep 17 00:00:00 2001 From: Scott Bucher Date: Sun, 2 Jul 2023 00:08:01 -0400 Subject: [PATCH] add shard counts for top.gg --- config/bot-sites.example.json | 2 +- src/jobs/update-server-count-job.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config/bot-sites.example.json b/config/bot-sites.example.json index fd40ecc6..0211f2a6 100644 --- a/config/bot-sites.example.json +++ b/config/bot-sites.example.json @@ -4,7 +4,7 @@ "enabled": false, "url": "https://top.gg/api/bots//stats", "authorization": "", - "body": "{\"server_count\":{{SERVER_COUNT}}}" + "body": "{\"server_count\":{{SERVER_COUNT}},\"shard_count\":{{SHARD_COUNT}}}" }, { "name": "bots.ondiscord.xyz", diff --git a/src/jobs/update-server-count-job.ts b/src/jobs/update-server-count-job.ts index c4fd5134..f681f540 100644 --- a/src/jobs/update-server-count-job.ts +++ b/src/jobs/update-server-count-job.ts @@ -25,6 +25,7 @@ export class UpdateServerCountJob implements Job { public async run(): Promise { let serverCount = await ShardUtils.serverCount(this.shardManager); + let shardCount = ShardUtils.shardIds(this.shardManager).length.toString(); let type = ActivityType.Streaming; let name = `to ${serverCount.toLocaleString()} servers`; @@ -44,7 +45,9 @@ export class UpdateServerCountJob implements Job { for (let botSite of this.botSites) { try { let body = JSON.parse( - botSite.body.replaceAll('{{SERVER_COUNT}}', serverCount.toString()) + botSite.body + .replaceAll('{{SERVER_COUNT}}', serverCount.toString()) + .replaceAll('{{SHARD_COUNT}}', shardCount) ); let res = await this.httpService.post(botSite.url, botSite.authorization, body);