mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-16 06:35:03 +00:00
20 lines
608 B
TypeScript
20 lines
608 B
TypeScript
import { ThreadChannel } from "discord.js";
|
|
import * as t from "io-ts";
|
|
import { noop } from "../../../utils";
|
|
import { automodAction } from "../helpers";
|
|
|
|
export const ArchiveThreadAction = automodAction({
|
|
configType: t.type({}),
|
|
defaultConfig: {},
|
|
|
|
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 ThreadChannel => c?.isThread() ?? false);
|
|
|
|
for (const thread of threads) {
|
|
await thread.setArchived().catch(noop);
|
|
}
|
|
},
|
|
});
|