From 3a95a1bedae4014fd5f1247a092fb97bff818be1 Mon Sep 17 00:00:00 2001 From: LTS20050703 Date: Mon, 5 Sep 2022 00:02:42 +0700 Subject: [PATCH] feat: Adds mention limits in automod (#2414) * Adds mention limits in automod * add mention limit to automod helper, transformer * helpers/automod: send mention_total_limit to discord --- helpers/guilds/automod/createAutomodRule.ts | 3 +++ helpers/guilds/automod/editAutomodRule.ts | 3 +++ transformers/automodRule.ts | 1 + types/discord.ts | 3 +++ 4 files changed, 10 insertions(+) diff --git a/helpers/guilds/automod/createAutomodRule.ts b/helpers/guilds/automod/createAutomodRule.ts index ce2804a6c..c46504d97 100644 --- a/helpers/guilds/automod/createAutomodRule.ts +++ b/helpers/guilds/automod/createAutomodRule.ts @@ -26,6 +26,7 @@ export async function createAutomodRule( keyword_filter: options.triggerMetadata.keywordFilter, presets: options.triggerMetadata.presets, allow_list: options.triggerMetadata.allowList, + mention_total_limit: options.triggerMetadata.mentionTotalLimit, }, actions: options.actions.map((action) => ({ type: action.type, @@ -61,6 +62,8 @@ export interface CreateAutoModerationRuleOptions { presets?: DiscordAutoModerationRuleTriggerMetadataPresets[]; /** The substrings which will exempt from triggering the preset trigger type. Only present when TriggerType.KeywordPreset */ allowList?: string[]; + /** Total number of mentions (role & user) allowed per message (Maximum of 50) */ + mentionTotalLimit: number; }; /** The actions that will trigger for this rule */ actions: { diff --git a/helpers/guilds/automod/editAutomodRule.ts b/helpers/guilds/automod/editAutomodRule.ts index 928186a19..04563b002 100644 --- a/helpers/guilds/automod/editAutomodRule.ts +++ b/helpers/guilds/automod/editAutomodRule.ts @@ -25,6 +25,7 @@ export async function editAutomodRule( keyword_filter: options.triggerMetadata.keywordFilter, presets: options.triggerMetadata.presets, allow_list: options.triggerMetadata.allowList, + mention_total_limit: options.triggerMetadata.mentionTotalLimit, } : undefined, actions: options.actions?.map((action) => ({ @@ -58,6 +59,8 @@ export interface EditAutoModerationRuleOptions { presets?: DiscordAutoModerationRuleTriggerMetadataPresets[]; /** The substrings which will exempt from triggering the preset trigger type. Only present when TriggerType.KeywordPreset */ allowList?: string[]; + /** Total number of mentions (role & user) allowed per message (Maximum of 50) */ + mentionTotalLimit: number; }; /** The actions that will trigger for this rule */ actions: { diff --git a/transformers/automodRule.ts b/transformers/automodRule.ts index 31822b622..7e6ff7689 100644 --- a/transformers/automodRule.ts +++ b/transformers/automodRule.ts @@ -18,6 +18,7 @@ export function transformAutoModerationRule(bot: Bot, payload: DiscordAutoModera keywordFilter: payload.trigger_metadata.keyword_filter, presets: payload.trigger_metadata.presets, allowList: payload.trigger_metadata.allow_list, + mentionTotalLimit: payload.trigger_metadata.mention_total_limit, } : undefined, actions: payload.actions.map((action) => ({ diff --git a/types/discord.ts b/types/discord.ts index 9998c55ce..0f2734a36 100644 --- a/types/discord.ts +++ b/types/discord.ts @@ -1454,6 +1454,7 @@ export enum AutoModerationTriggerTypes { HarmfulLink, Spam, KeywordPreset, + MentionSpam, } export interface DiscordAutoModerationRuleTriggerMetadata { @@ -1464,6 +1465,8 @@ export interface DiscordAutoModerationRuleTriggerMetadata { presets?: DiscordAutoModerationRuleTriggerMetadataPresets[]; /** The substrings which will exempt from triggering the preset trigger type. Only present when TriggerType.KeywordPreset */ allow_list: string[]; + /** Total number of mentions (role & user) allowed per message (Maximum of 50) */ + mention_total_limit: number; } export enum DiscordAutoModerationRuleTriggerMetadataPresets {