add: THREAD_UPDATE event handler

This commit is contained in:
ITOH
2021-05-02 20:51:09 +02:00
parent b148c67b6c
commit 5e747a8cdf
+16
View File
@@ -0,0 +1,16 @@
import { eventHandlers } from "../../bot.ts";
import { cacheHandlers } from "../../cache.ts";
import { structures } from "../../structures/mod.ts";
import { Channel } from "../../types/channels/channel.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
export async function handleThreadUpdate(data: DiscordGatewayPayload) {
const payload = data.d as Channel;
const oldChannel = await cacheHandlers.get("channels", payload.id);
if (!oldChannel) return;
const discordenoChannel = await structures.createDiscordenoChannel(payload);
await cacheHandlers.set("channels", discordenoChannel.id, discordenoChannel);
eventHandlers.threadUpdate?.(discordenoChannel, oldChannel);
}