swc/crates/swc_bundler/tests/.cache/deno/7892e5f52128fa044be9b5f46e7ad506d0475139.ts
2021-11-09 20:42:49 +09:00

22 lines
926 B
TypeScript

// Loaded from https://deno.land/x/discordeno@11.0.0-rc.2/src/handlers/messages/MESSAGE_DELETE_BULK.ts
import { eventHandlers } from "../../bot.ts";
import { cacheHandlers } from "../../cache.ts";
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
import type { MessageDeleteBulk } from "../../types/messages/message_delete_bulk.ts";
import { snowflakeToBigint } from "../../util/bigint.ts";
export async function handleMessageDeleteBulk(data: DiscordGatewayPayload) {
const payload = data.d as MessageDeleteBulk;
const channel = await cacheHandlers.get("channels", snowflakeToBigint(payload.channelId));
if (!channel) return;
return Promise.all(
payload.ids.map(async (id) => {
eventHandlers.messageDelete?.({ id, channel }, await cacheHandlers.get("messages", snowflakeToBigint(id)));
await cacheHandlers.delete("messages", snowflakeToBigint(id));
})
);
}