mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 14:11:50 +00:00
add unarchive_thread
This commit is contained in:
parent
c84d1a0be1
commit
00bb477903
2 changed files with 30 additions and 0 deletions
|
@ -15,6 +15,7 @@ import { ReplyAction } from "./reply";
|
||||||
import { SetAntiraidLevelAction } from "./setAntiraidLevel";
|
import { SetAntiraidLevelAction } from "./setAntiraidLevel";
|
||||||
import { SetCounterAction } from "./setCounter";
|
import { SetCounterAction } from "./setCounter";
|
||||||
import { SetSlowmodeAction } from "./setSlowmode";
|
import { SetSlowmodeAction } from "./setSlowmode";
|
||||||
|
import { UnArchiveThreadAction } from "./unArchiveThread";
|
||||||
import { WarnAction } from "./warn";
|
import { WarnAction } from "./warn";
|
||||||
|
|
||||||
export const availableActions: Record<string, AutomodActionBlueprint<any>> = {
|
export const availableActions: Record<string, AutomodActionBlueprint<any>> = {
|
||||||
|
@ -34,6 +35,7 @@ export const availableActions: Record<string, AutomodActionBlueprint<any>> = {
|
||||||
set_counter: SetCounterAction,
|
set_counter: SetCounterAction,
|
||||||
set_slowmode: SetSlowmodeAction,
|
set_slowmode: SetSlowmodeAction,
|
||||||
archive_thread: ArchiveThreadAction,
|
archive_thread: ArchiveThreadAction,
|
||||||
|
unarchive_thread: UnArchiveThreadAction,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AvailableActions = t.type({
|
export const AvailableActions = t.type({
|
||||||
|
@ -53,4 +55,5 @@ export const AvailableActions = t.type({
|
||||||
set_counter: SetCounterAction.configType,
|
set_counter: SetCounterAction.configType,
|
||||||
set_slowmode: SetSlowmodeAction.configType,
|
set_slowmode: SetSlowmodeAction.configType,
|
||||||
archive_thread: ArchiveThreadAction.configType,
|
archive_thread: ArchiveThreadAction.configType,
|
||||||
|
unarchive_thread: UnArchiveThreadAction.configType,
|
||||||
});
|
});
|
||||||
|
|
27
backend/src/plugins/Automod/actions/unArchiveThread.ts
Normal file
27
backend/src/plugins/Automod/actions/unArchiveThread.ts
Normal 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.message?.channel_id)
|
||||||
|
.map((c) => pluginData.guild.channels.cache.get(c.message!.channel_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);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
Loading…
Add table
Reference in a new issue