Add archive_thread action to automod (#271)

This commit is contained in:
Almeida 2021-09-04 17:37:49 +01:00 committed by GitHub
parent 98f7c27dd4
commit b3e2e0cffb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View file

@ -0,0 +1,20 @@
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);
}
},
});