mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
feat(automod): add affects_self option for rules
This commit is contained in:
parent
1f4f27c26a
commit
151a5df4af
3 changed files with 6 additions and 5 deletions
|
@ -81,6 +81,10 @@ const configPreprocessor: ConfigPreprocessorFn<AutomodPluginType> = (options) =>
|
||||||
rule["affects_bots"] = false;
|
rule["affects_bots"] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rule["affects_self"] == null) {
|
||||||
|
rule["affects_self"] = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Loop through the rule's triggers
|
// Loop through the rule's triggers
|
||||||
if (rule["triggers"]) {
|
if (rule["triggers"]) {
|
||||||
for (const triggerObj of rule["triggers"]) {
|
for (const triggerObj of rule["triggers"]) {
|
||||||
|
|
|
@ -23,11 +23,6 @@ export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>,
|
||||||
const channel = channelOrThread?.isThread() ? channelOrThread.parent : channelOrThread;
|
const channel = channelOrThread?.isThread() ? channelOrThread.parent : channelOrThread;
|
||||||
const categoryId = channel?.parentId;
|
const categoryId = channel?.parentId;
|
||||||
|
|
||||||
// Don't apply Automod on Zeppelin itself
|
|
||||||
if (userId && userId === pluginData.client.user?.id) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const config = await pluginData.config.getMatchingConfig({
|
const config = await pluginData.config.getMatchingConfig({
|
||||||
channelId,
|
channelId,
|
||||||
categoryId,
|
categoryId,
|
||||||
|
@ -39,6 +34,7 @@ export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>,
|
||||||
for (const [ruleName, rule] of Object.entries(config.rules)) {
|
for (const [ruleName, rule] of Object.entries(config.rules)) {
|
||||||
if (rule.enabled === false) continue;
|
if (rule.enabled === false) continue;
|
||||||
if (!rule.affects_bots && (!user || user.bot) && !context.counterTrigger && !context.antiraid) continue;
|
if (!rule.affects_bots && (!user || user.bot) && !context.counterTrigger && !context.antiraid) continue;
|
||||||
|
if (!rule.affects_self && userId && userId === pluginData.client.user?.id) continue;
|
||||||
|
|
||||||
if (rule.cooldown && checkAndUpdateCooldown(pluginData, rule, context)) {
|
if (rule.cooldown && checkAndUpdateCooldown(pluginData, rule, context)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -23,6 +23,7 @@ export const Rule = t.type({
|
||||||
name: t.string,
|
name: t.string,
|
||||||
presets: tNullable(t.array(t.string)),
|
presets: tNullable(t.array(t.string)),
|
||||||
affects_bots: t.boolean,
|
affects_bots: t.boolean,
|
||||||
|
affects_self: t.boolean,
|
||||||
triggers: t.array(t.partial(AvailableTriggers.props)),
|
triggers: t.array(t.partial(AvailableTriggers.props)),
|
||||||
actions: t.partial(AvailableActions.props),
|
actions: t.partial(AvailableActions.props),
|
||||||
cooldown: tNullable(t.string),
|
cooldown: tNullable(t.string),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue