fix(gateway): Use gateway instead of options in functions (#5169)

This commit is contained in:
Fleny
2026-07-23 01:29:27 +05:30
committed by GitHub
parent 94d14db0ec
commit 6c57211303
+4 -4
View File
@@ -186,14 +186,14 @@ export function createGatewayManager(options: CreateGatewayManagerOptions): Gate
// Move the events from the old shards to the new ones
for (const shard of gateway.resharding.shards.values()) {
shard.events = options.events ?? {};
shard.events = gateway.events ?? {};
}
// Old shards stop processing events
for (const shard of gateway.shards.values()) {
const oldHandler = shard.events.message;
// Change with spread operator to not affect new shards, as changing anything on shard.events will directly change options.events, which changes new shards' events
// Change with spread operator to not affect new shards, as changing anything on shard.events will directly change gateway.events, which changes new shards' events
shard.events = {
...shard.events,
message: async function (_, message) {
@@ -232,7 +232,7 @@ export function createGatewayManager(options: CreateGatewayManagerOptions): Gate
);
},
calculateWorkerId(shardId) {
const workerId = options.spreadShardsInRoundRobin
const workerId = gateway.spreadShardsInRoundRobin
? shardId % gateway.totalWorkers
: Math.min(Math.floor(shardId / gateway.shardsPerWorker), gateway.totalWorkers - 1);
gateway.logger.debug(
@@ -354,7 +354,7 @@ export function createGatewayManager(options: CreateGatewayManagerOptions): Gate
url: this.url,
version: this.version,
},
events: options.events ?? {},
events: gateway.events ?? {},
logger: this.logger,
requestIdentify: async () => await gateway.requestIdentify(shardId),
makePresence: gateway.makePresence,