function checkReady(
  payload,
  shard,
) {
  // Check if all guilds were loaded
  if (!shard.unavailableGuildIds.size) return loaded(shard);
  // If the last GUILD_CREATE has been received before 5 seconds if so most likely the remaining guilds are unavailable
  if (shard.lastAvailable + 5000 < Date.now()) {
    eventHandlers.shardFailedToLoad?.(shard.id, shard.unavailableGuildIds);
    // Force execute the loaded function to prevent infinite loop
    return loaded(shard);
  }
  // Not all guilds were loaded but 5 seconds haven't passed so check again
  setTimeout(() => {
    eventHandlers.debug?.("loop", `2. Running setTimeout in READY file.`);
    checkReady(payload, shard);
  }, 2000);
}
/** This function checks if the shard is fully loaded */
This function checks if the shard is fully loaded
This function checks if the shard is fully loaded
function checkReady(
  payload,
  shard,
) {
  if (!shard.unavailableGuildIds.size) return loaded(shard);
  if (shard.lastAvailable + 5000 < Date.now()) {
    eventHandlers.shardFailedToLoad?.(shard.id, shard.unavailableGuildIds);
    return loaded(shard);
  }
  setTimeout(() => {
    eventHandlers.debug?.("loop", `2. Running setTimeout in READY file.`);
    checkReady(payload, shard);
  }, 2000);
}
function checkReady ( payload , shard , ) { if ( ! shard . unavailableGuildIds . size ) return loaded ( shard ) ; if ( shard . lastAvailable + 5000 < Date . now ( ) ) { eventHandlers . shardFailedToLoad ?. ( shard . id , shard . unavailableGuildIds ) ; return loaded ( shard ) ; } setTimeout ( ( ) => { eventHandlers . debug ?. ( "loop" , ` ` ) ; checkReady ( payload , shard ) ; } , 2000 ) ; }
This function checks if the shard is fully loaded
This function checks if the shard is fully loaded
// Check if all guilds were loaded // If the last GUILD_CREATE has been received before 5 seconds if so most likely the remaining guilds are unavailable // Force execute the loaded function to prevent infinite loop // Not all guilds were loaded but 5 seconds haven't passed so check again