async function startGateway(options) {
  ws.identifyPayload.token = `Bot ${options.token}`;
  ws.secretKey = options.secretKey;
  ws.firstShardId = options.firstShardId;
  ws.url = options.url;
  if (options.shardsPerCluster) ws.shardsPerCluster = options.shardsPerCluster;
  if (options.maxClusters) ws.maxClusters = options.maxClusters;
  if (options.compress) {
    ws.identifyPayload.compress = options.compress;
  }
  if (options.reshard) ws.reshard = options.reshard;
  // Once an hour check if resharding is necessary
  setInterval(ws.resharder, 1000 * 60 * 60);
  ws.identifyPayload.intents = options.intents.reduce(
    (bits, next) =>
      bits |= typeof next === "string" ? DiscordGatewayIntents[next] : next,
    0,
  );
  ws.botGatewayData = camelize(
    await fetch(`https://discord.com/api/gateway/bot`, {
      headers: {
        Authorization: ws.identifyPayload.token,
      },
    }).then((res) => res.json()),
  );
  ws.maxShards = options.maxShards || ws.botGatewayData.shards;
  ws.lastShardId = options.lastShardId || ws.botGatewayData.shards - 1;
  ws.spawnShards(ws.firstShardId);
  await ws.cleanupLoadingShards();
}
/** ADVANCED DEVS ONLY!!!!!!
 * Starts the standalone gateway.
 * This will require starting the bot separately.
 */
ADVANCED DEVS ONLY
Starts the standalone gateway.
This will require starting the bot separately.
ADVANCED DEVS ONLY Starts the standalone gateway . This will require starting the bot separately .
async function startGateway(options) {
  ws.identifyPayload.token = `Bot ${options.token}`;
  ws.secretKey = options.secretKey;
  ws.firstShardId = options.firstShardId;
  ws.url = options.url;
  if (options.shardsPerCluster) ws.shardsPerCluster = options.shardsPerCluster;
  if (options.maxClusters) ws.maxClusters = options.maxClusters;
  if (options.compress) {
    ws.identifyPayload.compress = options.compress;
  }
  if (options.reshard) ws.reshard = options.reshard;
  setInterval(ws.resharder, 1000 * 60 * 60);
  ws.identifyPayload.intents = options.intents.reduce(
    (bits, next) =>
      bits |= typeof next === "string" ? DiscordGatewayIntents[next] : next,
    0,
  );
  ws.botGatewayData = camelize(
    await fetch(`https://discord.com/api/gateway/bot`, {
      headers: {
        Authorization: ws.identifyPayload.token,
      },
    }).then((res) => res.json()),
  );
  ws.maxShards = options.maxShards || ws.botGatewayData.shards;
  ws.lastShardId = options.lastShardId || ws.botGatewayData.shards - 1;
  ws.spawnShards(ws.firstShardId);
  await ws.cleanupLoadingShards();
}
async function startGateway ( options ) { ws . identifyPayload . token = ` ${ options . token } ` ; ws . secretKey = options . secretKey ; ws . firstShardId = options . firstShardId ; ws . url = options . url ; if ( options . shardsPerCluster ) ws . shardsPerCluster = options . shardsPerCluster ; if ( options . maxClusters ) ws . maxClusters = options . maxClusters ; if ( options . compress ) { ws . identifyPayload . compress = options . compress ; } if ( options . reshard ) ws . reshard = options . reshard ; setInterval ( ws . resharder , 1000 * 60 * 60 ) ; ws . identifyPayload . intents = options . intents . reduce ( ( bits , next ) => bits |= typeof next === "string" ? DiscordGatewayIntents [ next ] : next , 0 , ) ; ws . botGatewayData = camelize ( await fetch ( ` ` , { headers : { Authorization : ws . identifyPayload . token , } , } ) . then ( ( res ) => res . json ( ) ) , ) ; ws . maxShards = options . maxShards || ws . botGatewayData . shards ; ws . lastShardId = options . lastShardId || ws . botGatewayData . shards - 1 ; ws . spawnShards ( ws . firstShardId ) ; await ws . cleanupLoadingShards ( ) ; }
ADVANCED DEVS ONLY!!!!!!
ADVANCED DEVS ONLY!!!!!!
// Once an hour check if resharding is necessary