3
0
Fork 0
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:
Dragory 2020-07-30 01:45:14 +03:00
parent 6324b9654b
commit ae97a5dded
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
16 changed files with 64 additions and 19 deletions

View file

@ -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));

View file

@ -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);

View file

@ -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));

View file

@ -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));

View file

@ -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();

View file

@ -6,6 +6,8 @@ export const ExampleAction = automodAction({
someValue: t.string,
}),
defaultConfig: {},
async apply({ pluginData, contexts, actionConfig }) {
// TODO: Everything
},

View file

@ -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));

View file

@ -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);

View file

@ -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));

View file

@ -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));

View file

@ -23,6 +23,8 @@ export const ReplyAction = automodAction({
}),
]),
defaultConfig: {},
async apply({ pluginData, contexts, actionConfig }) {
const contextsWithTextChannels = contexts
.filter(c => c.message?.channel_id)

View file

@ -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);

View file

@ -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));