mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
Automod actions + ModActions public interface
This commit is contained in:
parent
0f0728bc1c
commit
86023877a2
22 changed files with 508 additions and 16 deletions
36
backend/src/plugins/Automod/actions/mute.ts
Normal file
36
backend/src/plugins/Automod/actions/mute.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
import * as t from "io-ts";
|
||||
import { automodAction } from "../helpers";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { asyncMap, convertDelayStringToMS, resolveMember, tDelayString, tNullable } from "../../../utils";
|
||||
import { resolveActionContactMethods } from "../functions/resolveActionContactMethods";
|
||||
import { ModActionsPlugin } from "../../ModActions/ModActionsPlugin";
|
||||
import { MutesPlugin } from "../../Mutes/MutesPlugin";
|
||||
|
||||
export const MuteAction = automodAction({
|
||||
configType: t.type({
|
||||
reason: tNullable(t.string),
|
||||
duration: tNullable(tDelayString),
|
||||
notify: tNullable(t.string),
|
||||
notifyChannel: tNullable(t.string),
|
||||
}),
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig }) {
|
||||
const duration = actionConfig.duration ? convertDelayStringToMS(actionConfig.duration) : null;
|
||||
const reason = actionConfig.reason || "Muted automatically";
|
||||
const contactMethods = resolveActionContactMethods(pluginData, actionConfig);
|
||||
|
||||
const caseArgs = {
|
||||
modId: pluginData.client.user.id,
|
||||
extraNotes: [
|
||||
/* TODO */
|
||||
],
|
||||
};
|
||||
|
||||
const userIdsToMute = contexts.map(c => c.user?.id).filter(Boolean);
|
||||
|
||||
const mutes = pluginData.getPlugin(MutesPlugin);
|
||||
for (const userId of userIdsToMute) {
|
||||
await mutes.muteUser(userId, duration, reason, { contactMethods, caseArgs });
|
||||
}
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue