From e580734d0b28d4cf703ce3f03b39a33232e975e7 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Thu, 17 Nov 2022 00:57:13 +0300 Subject: [PATCH] Regex patterns automod rule trigger (#1275) * feat: add regex pattern automod trigger Add regex patterns metadata to AutoModerationTriggerMetadata. * feat: add regex pattern example Add showcase of regex filter into auto_moderation example. * feat: cosmetic changes Add period to the end of RegexPatterns documentation comment. --- examples/auto_moderation/main.go | 1 + structs.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/examples/auto_moderation/main.go b/examples/auto_moderation/main.go index 66fbbcb..9b617d7 100644 --- a/examples/auto_moderation/main.go +++ b/examples/auto_moderation/main.go @@ -32,6 +32,7 @@ func main() { TriggerType: discordgo.AutoModerationEventTriggerKeyword, TriggerMetadata: &discordgo.AutoModerationTriggerMetadata{ KeywordFilter: []string{"*cat*"}, + RegexPatterns: []string{"(c|b)at"}, }, Enabled: &enabled, diff --git a/structs.go b/structs.go index f2cdc69..9955e89 100644 --- a/structs.go +++ b/structs.go @@ -1427,6 +1427,10 @@ type AutoModerationTriggerMetadata struct { // Substrings which will be searched for in content. // NOTE: should be only used with keyword trigger type. KeywordFilter []string `json:"keyword_filter,omitempty"` + // Regular expression patterns which will be matched against content (maximum of 10). + // NOTE: should be only used with keyword trigger type. + RegexPatterns []string `json:"regex_patterns,omitempty"` + // Internally pre-defined wordsets which will be searched for in content. // NOTE: should be only used with keyword preset trigger type. Presets []AutoModerationKeywordPreset `json:"presets,omitempty"`