Files
discordeno/src/handlers/messages/MESSAGE_DELETE.ts
T
2021-04-24 23:17:11 +02:00

18 lines
643 B
TypeScript

import { eventHandlers } from "../../bot.ts";
import { cacheHandlers } from "../../cache.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
import { MessageDelete } from "../../types/messages/message_delete.ts";
export async function handleMessageDelete(data: DiscordGatewayPayload) {
const payload = data.d as MessageDelete;
const channel = await cacheHandlers.get("channels", payload.channelId);
if (!channel) return;
eventHandlers.messageDelete?.(
{ id: payload.id, channel },
await cacheHandlers.get("messages", payload.id),
);
await cacheHandlers.delete("messages", payload.id);
}