fix(bot): keep an explicit lastShardId of 0 in bot.start() (#5382)

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 <noreply@anthropic.com>
Co-authored-by: Fleny <Fleny113@outlook.com>
This commit is contained in:
NotDemonix
2026-08-30 17:37:22 +02:00
committed by GitHub
co-authored by Claude Opus 5 Fleny
parent 62a4478de8
commit 93786b6740
+3 -1
View File
@@ -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) {