mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 04:25:01 +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;
|
||||
}
|
||||
|
||||
if (rule["affects_self"] == null) {
|
||||
rule["affects_self"] = false;
|
||||
}
|
||||
|
||||
// Loop through the rule's triggers
|
||||
if (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 categoryId = channel?.parentId;
|
||||
|
||||
// Don't apply Automod on Zeppelin itself
|
||||
if (userId && userId === pluginData.client.user?.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
const config = await pluginData.config.getMatchingConfig({
|
||||
channelId,
|
||||
categoryId,
|
||||
|
@ -39,6 +34,7 @@ export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>,
|
|||
for (const [ruleName, rule] of Object.entries(config.rules)) {
|
||||
if (rule.enabled === false) 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)) {
|
||||
continue;
|
||||
|
|
|
@ -23,6 +23,7 @@ export const Rule = t.type({
|
|||
name: t.string,
|
||||
presets: tNullable(t.array(t.string)),
|
||||
affects_bots: t.boolean,
|
||||
affects_self: t.boolean,
|
||||
triggers: t.array(t.partial(AvailableTriggers.props)),
|
||||
actions: t.partial(AvailableActions.props),
|
||||
cooldown: tNullable(t.string),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue