From 73452f43f59c33d5f0ebd700238dcb202a372684 Mon Sep 17 00:00:00 2001 From: Awesome Stickz Date: Thu, 1 Sep 2022 23:04:48 +0530 Subject: [PATCH] fix: ignore GUILD_DELETE events for unavailable guilds in big bot template (#2412) * fix: ignore GUILD_DELETE events for unavailable guilds in big bot template * update worker.ts Co-authored-by: LTS20050703 * fix: small stuff Co-authored-by: LTS20050703 --- template/bigbot/src/gateway/worker.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/template/bigbot/src/gateway/worker.ts b/template/bigbot/src/gateway/worker.ts index 195c129d2..b48574064 100644 --- a/template/bigbot/src/gateway/worker.ts +++ b/template/bigbot/src/gateway/worker.ts @@ -1,4 +1,4 @@ -import { createShardManager, Shard, ShardSocketRequest, ShardState } from "discordeno"; +import { createShardManager, DiscordUnavailableGuild, Shard, ShardSocketRequest, ShardState } from "discordeno"; import { createLogger } from "discordeno/logger"; import { parentPort, workerData } from "worker_threads"; import { ManagerMessage } from "./index.js"; @@ -24,6 +24,9 @@ const manager = createShardManager({ const url = script.handlerUrls[shard.id % script.handlerUrls.length]; if (!url) return console.log("ERROR: NO URL FOUND TO SEND MESSAGE"); + // MUST HANDLE GUILD_DELETE EVENTS FOR UNAVAILABLE + if (message.t === "GUILD_DELETE" && (message.d as DiscordUnavailableGuild).unavailable) return; + await fetch(url, { method: "POST", body: JSON.stringify({ message, shardId: shard.id }),