3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-23 17:45:03 +00:00
This commit is contained in:
metal 2021-09-14 15:31:44 +00:00 committed by almeidx
parent d23e430711
commit 3a36b3e5ef
No known key found for this signature in database
GPG key ID: F403F80B79353CB4

View file

@ -0,0 +1,27 @@
import { ThreadChannel } from "discord.js";
import * as t from "io-ts";
import { noop, tNullable } from "../../../utils";
import { automodAction } from "../helpers";
export const UnArchiveThreadAction = automodAction({
configType: t.type({
unlock: tNullable(t.boolean),
}),
defaultConfig: {
unlock: false,
},
async apply({ pluginData, contexts, actionConfig }) {
const threads = contexts
.filter(c => c.thread?.id)
.map(c => pluginData.guild.channels.cache.get(c.thread!.id))
.filter((c): c is ThreadChannel => (c?.isThread() && c.archived) ?? false);
for (const thread of threads) {
if (actionConfig.unlock) {
await thread.setLocked(false).catch(noop);
}
await thread.setArchived(false).catch(noop);
}
},
});