mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-01 00:10:07 +00:00
Wait for a random amount of time between 1 and 5 seconds before resuming
This commit is contained in:
@@ -4,6 +4,7 @@ import { DiscordGatewayOpcodes } from "../types/codes/gateway_opcodes.ts";
|
||||
import { DiscordGatewayPayload } from "../types/gateway/gateway_payload.ts";
|
||||
import { DiscordHello } from "../types/gateway/hello.ts";
|
||||
import { DiscordReady } from "../types/gateway/ready.ts";
|
||||
import { delay } from "../util/utils.ts";
|
||||
import { decompressWith } from "./deps.ts";
|
||||
import { identify } from "./identify.ts";
|
||||
import { resume } from "./resume.ts";
|
||||
@@ -66,6 +67,9 @@ export async function handleOnMessage(message: any, shardId: number) {
|
||||
case DiscordGatewayOpcodes.InvalidSession:
|
||||
ws.log("INVALID_SESSION", { shardId, payload: messageData });
|
||||
|
||||
// We need to wait for a random amount of time between 1 and 5
|
||||
await delay(Math.floor((Math.random() * 4 + 1) * 1000));
|
||||
|
||||
// When d is false we need to reidentify
|
||||
if (!messageData.d) {
|
||||
await identify(shardId, ws.maxShards);
|
||||
|
||||
Reference in New Issue
Block a user