zappyzep/backend/src/plugins/Automod/actions/archiveThread.ts
2024-01-14 14:25:42 +00:00

21 lines
622 B
TypeScript

import { AnyThreadChannel } from "discord.js";
import z from "zod";
import { noop } from "../../../utils";
import { automodAction } from "../helpers";
const configSchema = z.strictObject({});
export const ArchiveThreadAction = automodAction({
configSchema,
async apply({ pluginData, contexts }) {
const threads = contexts
.filter((c) => c.message?.channel_id)
.map((c) => pluginData.guild.channels.cache.get(c.message!.channel_id))
.filter((c): c is AnyThreadChannel => c?.isThread() ?? false);
for (const thread of threads) {
await thread.setArchived().catch(noop);
}
},
});