Files
discordeno/src/handlers/channels/THREAD_DELETE.ts
T
2021-07-08 19:47:54 +02:00

18 lines
755 B
TypeScript

import { eventHandlers } from "../../bot.ts";
import { cacheHandlers } from "../../cache.ts";
import { Channel } from "../../types/channels/channel.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
import { snowflakeToBigint } from "../../util/bigint.ts";
export async function handleThreadDelete(data: DiscordGatewayPayload) {
const payload = data.d as Channel;
const cachedChannel = await cacheHandlers.get("threads", snowflakeToBigint(payload.id));
if (!cachedChannel) return;
await cacheHandlers.delete("threads", snowflakeToBigint(payload.id));
await cacheHandlers.forEach("DELETE_MESSAGES_FROM_CHANNEL", { channelId: snowflakeToBigint(payload.id) });
eventHandlers.threadDelete?.(cachedChannel);
}