mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-11 04:45:02 +00:00
automod: add default configs for actions
This commit is contained in:
parent
6324b9654b
commit
ae97a5dded
16 changed files with 64 additions and 19 deletions
|
@ -7,6 +7,7 @@ import { ModActionsPlugin } from "../../ModActions/ModActionsPlugin";
|
|||
|
||||
export const AddRolesAction = automodAction({
|
||||
configType: t.array(t.string),
|
||||
defaultConfig: [],
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig }) {
|
||||
const members = unique(contexts.map(c => c.member).filter(Boolean));
|
||||
|
|
|
@ -14,6 +14,8 @@ export const AlertAction = automodAction({
|
|||
text: t.string,
|
||||
}),
|
||||
|
||||
defaultConfig: {},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig, ruleName, matchResult }) {
|
||||
const channel = pluginData.guild.channels.get(actionConfig.channel);
|
||||
const logs = pluginData.getPlugin(LogsPlugin);
|
||||
|
|
|
@ -13,6 +13,10 @@ export const BanAction = automodAction({
|
|||
deleteMessageDays: tNullable(t.number),
|
||||
}),
|
||||
|
||||
defaultConfig: {
|
||||
notify: null, // Use defaults from ModActions
|
||||
},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig, matchResult }) {
|
||||
const reason = actionConfig.reason || "Kicked automatically";
|
||||
const contactMethods = resolveActionContactMethods(pluginData, actionConfig);
|
||||
|
@ -20,9 +24,7 @@ export const BanAction = automodAction({
|
|||
|
||||
const caseArgs = {
|
||||
modId: pluginData.client.user.id,
|
||||
extraNotes: [
|
||||
matchResult.summary, // TODO
|
||||
],
|
||||
extraNotes: [matchResult.fullSummary],
|
||||
};
|
||||
|
||||
const userIdsToBan = unique(contexts.map(c => c.user?.id).filter(Boolean));
|
||||
|
|
|
@ -9,6 +9,8 @@ export const ChangeNicknameAction = automodAction({
|
|||
name: t.string,
|
||||
}),
|
||||
|
||||
defaultConfig: {},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig }) {
|
||||
const members = unique(contexts.map(c => c.member).filter(Boolean));
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import { LogType } from "../../../data/LogType";
|
|||
|
||||
export const CleanAction = automodAction({
|
||||
configType: t.boolean,
|
||||
defaultConfig: false,
|
||||
|
||||
async apply({ pluginData, contexts }) {
|
||||
const messageIdsToDeleteByChannelId: Map<string, string[]> = new Map();
|
||||
|
|
|
@ -6,6 +6,8 @@ export const ExampleAction = automodAction({
|
|||
someValue: t.string,
|
||||
}),
|
||||
|
||||
defaultConfig: {},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig }) {
|
||||
// TODO: Everything
|
||||
},
|
||||
|
|
|
@ -12,15 +12,17 @@ export const KickAction = automodAction({
|
|||
notifyChannel: tNullable(t.string),
|
||||
}),
|
||||
|
||||
defaultConfig: {
|
||||
notify: null, // Use defaults from ModActions
|
||||
},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig, matchResult }) {
|
||||
const reason = actionConfig.reason || "Kicked automatically";
|
||||
const contactMethods = resolveActionContactMethods(pluginData, actionConfig);
|
||||
|
||||
const caseArgs = {
|
||||
modId: pluginData.client.user.id,
|
||||
extraNotes: [
|
||||
matchResult.summary, // TODO
|
||||
],
|
||||
extraNotes: [matchResult.fullSummary],
|
||||
};
|
||||
|
||||
const userIdsToKick = unique(contexts.map(c => c.user?.id).filter(Boolean));
|
||||
|
|
|
@ -6,6 +6,7 @@ import { stripObjectToScalars } from "../../../utils";
|
|||
|
||||
export const LogAction = automodAction({
|
||||
configType: t.boolean,
|
||||
defaultConfig: true,
|
||||
|
||||
async apply({ pluginData, contexts, ruleName, matchResult }) {
|
||||
const safeUsers = contexts.map(c => c.user && stripObjectToScalars(c.user)).filter(Boolean);
|
||||
|
|
|
@ -14,6 +14,10 @@ export const MuteAction = automodAction({
|
|||
notifyChannel: tNullable(t.string),
|
||||
}),
|
||||
|
||||
defaultConfig: {
|
||||
notify: null, // Use defaults from ModActions
|
||||
},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig, matchResult }) {
|
||||
const duration = actionConfig.duration ? convertDelayStringToMS(actionConfig.duration) : null;
|
||||
const reason = actionConfig.reason || "Muted automatically";
|
||||
|
@ -21,9 +25,7 @@ export const MuteAction = automodAction({
|
|||
|
||||
const caseArgs = {
|
||||
modId: pluginData.client.user.id,
|
||||
extraNotes: [
|
||||
matchResult.summary, // TODO
|
||||
],
|
||||
extraNotes: [matchResult.fullSummary],
|
||||
};
|
||||
|
||||
const userIdsToMute = unique(contexts.map(c => c.user?.id).filter(Boolean));
|
||||
|
|
|
@ -8,6 +8,8 @@ import { ModActionsPlugin } from "../../ModActions/ModActionsPlugin";
|
|||
export const RemoveRolesAction = automodAction({
|
||||
configType: t.array(t.string),
|
||||
|
||||
defaultConfig: [],
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig }) {
|
||||
const members = unique(contexts.map(c => c.member).filter(Boolean));
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ export const ReplyAction = automodAction({
|
|||
}),
|
||||
]),
|
||||
|
||||
defaultConfig: {},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig }) {
|
||||
const contextsWithTextChannels = contexts
|
||||
.filter(c => c.message?.channel_id)
|
||||
|
|
|
@ -4,6 +4,7 @@ import { setAntiraidLevel } from "../functions/setAntiraidLevel";
|
|||
|
||||
export const SetAntiraidLevelAction = automodAction({
|
||||
configType: t.string,
|
||||
defaultConfig: null,
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig }) {
|
||||
setAntiraidLevel(pluginData, actionConfig);
|
||||
|
|
|
@ -12,15 +12,17 @@ export const WarnAction = automodAction({
|
|||
notifyChannel: tNullable(t.string),
|
||||
}),
|
||||
|
||||
defaultConfig: {
|
||||
notify: null, // Use defaults from ModActions
|
||||
},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig, matchResult }) {
|
||||
const reason = actionConfig.reason || "Warned automatically";
|
||||
const contactMethods = resolveActionContactMethods(pluginData, actionConfig);
|
||||
|
||||
const caseArgs = {
|
||||
modId: pluginData.client.user.id,
|
||||
extraNotes: [
|
||||
matchResult.summary, // TODO
|
||||
],
|
||||
extraNotes: [matchResult.fullSummary],
|
||||
};
|
||||
|
||||
const userIdsToWarn = unique(contexts.map(c => c.user?.id).filter(Boolean));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue