async function resharder() {
  ws.botGatewayData = await getGatewayBot();
  const percentage = (ws.botGatewayData.shards - ws.maxShards) / ws.maxShards *
    100;
  // Less than necessary% being used so do nothing
  if (percentage < ws.reshardPercentage) return;
  // Don't have enough identify rate limits to reshard
  if (
    ws.botGatewayData.sessionStartLimit.remaining < ws.botGatewayData.shards
  ) {
    return;
  }
  // Begin resharding
  ws.maxShards = ws.botGatewayData.shards;
  // If more than 100K servers, begin switching to 16x sharding
  if (ws.maxShards && ws.useOptimalLargeBotSharding) {
    ws.maxShards = Math.ceil(
      ws.maxShards /
        (ws.botGatewayData.sessionStartLimit.maxConcurrency === 1
          ? 16
          : ws.botGatewayData.sessionStartLimit.maxConcurrency),
    );
  }
  ws.spawnShards(ws.firstShardId);
}
/** The handler to automatically reshard when necessary. */
The handler to automatically reshard when necessary.
The handler to automatically reshard when necessary .
async function resharder() {
  ws.botGatewayData = await getGatewayBot();
  const percentage = (ws.botGatewayData.shards - ws.maxShards) / ws.maxShards *
    100;
  if (percentage < ws.reshardPercentage) return;
  if (
    ws.botGatewayData.sessionStartLimit.remaining < ws.botGatewayData.shards
  ) {
    return;
  }
  ws.maxShards = ws.botGatewayData.shards;
  if (ws.maxShards && ws.useOptimalLargeBotSharding) {
    ws.maxShards = Math.ceil(
      ws.maxShards /
        (ws.botGatewayData.sessionStartLimit.maxConcurrency === 1
          ? 16
          : ws.botGatewayData.sessionStartLimit.maxConcurrency),
    );
  }
  ws.spawnShards(ws.firstShardId);
}
async function resharder ( ) { ws . botGatewayData = await getGatewayBot ( ) ; const percentage = ( ws . botGatewayData . shards - ws . maxShards ) / ws . maxShards * 100 ; if ( percentage < ws . reshardPercentage ) return ; if ( ws . botGatewayData . sessionStartLimit . remaining < ws . botGatewayData . shards ) { return ; } ws . maxShards = ws . botGatewayData . shards ; if ( ws . maxShards && ws . useOptimalLargeBotSharding ) { ws . maxShards = Math . ceil ( ws . maxShards / ( ws . botGatewayData . sessionStartLimit . maxConcurrency === 1 ? 16 : ws . botGatewayData . sessionStartLimit . maxConcurrency ) , ) ; } ws . spawnShards ( ws . firstShardId ) ; }
The handler to automatically reshard when necessary.
The handler to automatically reshard when necessary .
// Less than necessary% being used so do nothing // Don't have enough identify rate limits to reshard // Begin resharding // If more than 100K servers, begin switching to 16x sharding