mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 05:32:09 +03:00
22 lines
926 B
TypeScript
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));
|
|
})
|
|
);
|
|
}
|