automod: add role_added and role_removed triggers

This commit is contained in:
Dragory 2020-08-10 02:22:39 +03:00
parent bfa9cf55a7
commit 4c7a51f586
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
9 changed files with 187 additions and 4 deletions

View file

@ -27,6 +27,7 @@ import { RegExpRunner } from "../../RegExpRunner";
import { LogType } from "../../data/LogType";
import { logger } from "../../logger";
import { discardRegExpRunner, getRegExpRunner } from "../../regExpRunners";
import { RunAutomodOnMemberUpdate } from "./events/RunAutomodOnMemberUpdate";
const defaultOptions = {
config: {
@ -83,10 +84,15 @@ const configPreprocessor: ConfigPreprocessorFn<AutomodPluginType> = options => {
}
const triggerBlueprint = availableTriggers[triggerName];
triggerObj[triggerName] = configUtils.mergeConfig(
triggerBlueprint.defaultConfig,
triggerObj[triggerName] || {},
);
if (typeof triggerBlueprint.defaultConfig === "object" && triggerBlueprint.defaultConfig != null) {
triggerObj[triggerName] = configUtils.mergeConfig(
triggerBlueprint.defaultConfig,
triggerObj[triggerName] || {},
);
} else {
triggerObj[triggerName] = triggerObj[triggerName] || triggerBlueprint.defaultConfig;
}
if (triggerObj[triggerName].match_attachment_type) {
const white = triggerObj[triggerName].match_attachment_type.whitelist_enabled;
@ -157,6 +163,7 @@ export const AutomodPlugin = zeppelinPlugin<AutomodPluginType>()("automod", {
events: [
RunAutomodOnJoinEvt,
RunAutomodOnMemberUpdate,
// Messages use message events from SavedMessages, see onLoad below
],
@ -179,6 +186,8 @@ export const AutomodPlugin = zeppelinPlugin<AutomodPluginType>()("automod", {
30 * SECONDS,
);
pluginData.state.ignoredRoleChanges = new Set();
pluginData.state.cooldownManager = new CooldownManager();
pluginData.state.logs = new GuildLogs(pluginData.guild.id);