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 <lts20050703@gmail.com>

* fix: small stuff

Co-authored-by: LTS20050703 <lts20050703@gmail.com>
This commit is contained in:
Awesome Stickz
2022-09-01 12:34:48 -05:00
committed by GitHub
co-authored by LTS20050703
parent ae669e28fe
commit 73452f43f5
+4 -1
View File
@@ -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 }),