added allow_further_rules option to automod rules

This essentially makes it so you can run multiple rules at once
This commit is contained in:
Almeida 2021-05-08 15:35:05 +01:00 committed by almeidx
parent 0ec5e37286
commit eb61b5a653
No known key found for this signature in database
GPG key ID: 8558FBFF849BD664
3 changed files with 8 additions and 2 deletions

View file

@ -73,6 +73,10 @@ const configPreprocessor: ConfigPreprocessorFn<AutomodPluginType> = options => {
rule["enabled"] = true;
}
if (rule["allow_further_rules"] == null) {
rule["allow_further_rules"] = false;
}
if (rule["affects_bots"] == null) {
rule["affects_bots"] = false;
}

View file

@ -72,12 +72,13 @@ export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>,
matchResult.fullSummary = `Triggered automod rule **${ruleName}**\n${matchResult.summary}`.trim();
break triggerLoop;
if (!rule.allow_further_rules) break triggerLoop;
}
}
}
if (matchResult) {
console.log("matchResult exists");
for (const [actionName, actionConfig] of Object.entries(rule.actions)) {
if (actionConfig == null || actionConfig === false) {
continue;
@ -94,7 +95,7 @@ export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>,
});
}
break;
if (!rule.allow_further_rules) break;
}
}
}

View file

@ -26,6 +26,7 @@ export const Rule = t.type({
triggers: t.array(t.partial(AvailableTriggers.props)),
actions: t.partial(AvailableActions.props),
cooldown: tNullable(t.string),
allow_further_rules: t.boolean,
});
export type TRule = t.TypeOf<typeof Rule>;