Files
discordeno/src/handlers/messages/MESSAGE_DELETE.ts
T
ayntee 8654aeded5 refactor: rename controllers to handlers and handlers to helpers (#660)
* refactor: rename controllers to handlers and handlers to helpers

* fmt
2021-03-11 21:41:03 +04:00

17 lines
567 B
TypeScript

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