From 93786b674075f5bf48b93cad4bb548359b6add2b Mon Sep 17 00:00:00 2001 From: NotDemonix <90858555+NotDemonix@users.noreply.github.com> Date: Sun, 30 Aug 2026 17:37:22 +0200 Subject: [PATCH] fix(bot): keep an explicit lastShardId of 0 in bot.start() (#5382) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bot.start() derived lastShardId from the recommended shard count whenever `!options.gateway?.lastShardId` held, so an explicit `lastShardId: 0` — a valid single shard configuration — was treated as absent and overwritten, spawning every recommended shard in a process meant to run one. Compare against undefined instead. Co-authored-by: Claude Opus 5 Co-authored-by: Fleny --- packages/bot/src/bot.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/bot/src/bot.ts b/packages/bot/src/bot.ts index 398b9af78..5a134eef1 100644 --- a/packages/bot/src/bot.ts +++ b/packages/bot/src/bot.ts @@ -80,7 +80,9 @@ export function createBot< if (!options.gateway?.totalShards) bot.gateway.totalShards = bot.gateway.connection.shards; - if (!options.gateway?.lastShardId && !options.gateway?.totalShards) bot.gateway.lastShardId = bot.gateway.connection.shards - 1; + // `lastShardId: 0` is a valid single shard configuration, so an explicit id may not be treated as an absent one. + if (options.gateway?.lastShardId === undefined && options.gateway?.totalShards === undefined) + bot.gateway.lastShardId = bot.gateway.connection.shards - 1; } if (!bot.gateway.resharding.getSessionInfo) {