Files
discordeno/src/handlers/channels/CHANNEL_UPDATE.ts
T
2021-04-09 23:07:20 +02:00

18 lines
746 B
TypeScript

import { eventHandlers } from "../../bot.ts";
import { cacheHandlers } from "../../cache.ts";
import { structures } from "../../structures/mod.ts";
import { DiscordChannel } from "../../types/channels/channel.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
export async function handleChannelUpdate(data: DiscordGatewayPayload) {
const payload = data.d as DiscordChannel;
const cachedChannel = await cacheHandlers.get("channels", payload.id);
const discordenoChannel = await structures.createDiscordenoChannel(payload);
await cacheHandlers.set("channels", discordenoChannel.id, discordenoChannel);
if (!cachedChannel) return;
eventHandlers.channelUpdate?.(discordenoChannel, cachedChannel);
}