fix: move createNextShard to ws

This commit is contained in:
Skillz4Killz
2021-04-14 20:23:58 +00:00
committed by GitHub
parent de93b0ae20
commit ff5d086562
2 changed files with 7 additions and 6 deletions
+2 -6
View File
@@ -5,10 +5,10 @@ import { structures } from "../../structures/mod.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
import { DiscordReady } from "../../types/gateway/ready.ts"; import { DiscordReady } from "../../types/gateway/ready.ts";
import { DiscordGuildMemberWithUser } from "../../types/mod.ts"; import { DiscordGuildMemberWithUser } from "../../types/mod.ts";
import { camelKeysToSnakeCase, delay } from "../../util/utils.ts"; import { camelKeysToSnakeCase } from "../../util/utils.ts";
import { ws } from "../../ws/ws.ts"; import { ws } from "../../ws/ws.ts";
export async function handleReady( export function handleReady(
data: DiscordGatewayPayload, data: DiscordGatewayPayload,
shardId: number, shardId: number,
) { ) {
@@ -40,10 +40,6 @@ export async function handleReady(
); );
await checkReady(payload, shardId, now); await checkReady(payload, shardId, now);
}, 2000); }, 2000);
// Wait 5 seconds to spawn next shard
await delay(5000);
ws.createNextShard = true;
} }
// Don't pass the shard itself because unavailableGuilds won't be updated by the GUILD_CREATE event // Don't pass the shard itself because unavailableGuilds won't be updated by the GUILD_CREATE event
+5
View File
@@ -4,6 +4,7 @@ import { DiscordGatewayOpcodes } from "../types/codes/gateway_opcodes.ts";
import { DiscordGatewayPayload } from "../types/gateway/gateway_payload.ts"; import { DiscordGatewayPayload } from "../types/gateway/gateway_payload.ts";
import { DiscordHello } from "../types/gateway/hello.ts"; import { DiscordHello } from "../types/gateway/hello.ts";
import { DiscordReady } from "../types/gateway/ready.ts"; import { DiscordReady } from "../types/gateway/ready.ts";
import { delay } from "../util/utils.ts";
import { decompressWith } from "./deps.ts"; import { decompressWith } from "./deps.ts";
import { identify } from "./identify.ts"; import { identify } from "./identify.ts";
import { resume } from "./resume.ts"; import { resume } from "./resume.ts";
@@ -96,6 +97,10 @@ export async function handleOnMessage(message: any, shardId: number) {
ws.loadingShards.get(shardId)?.resolve(true); ws.loadingShards.get(shardId)?.resolve(true);
ws.loadingShards.delete(shardId); ws.loadingShards.delete(shardId);
// Wait 5 seconds to spawn next shard
setTimeout(() => {
ws.createNextShard = true;
}, 5000);
} }
// Update the sequence number if it is present // Update the sequence number if it is present