Skip to content

Commit

Permalink
Regex patterns automod rule trigger (bwmarrin#1275)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
FedorLap2006 authored Nov 16, 2022
1 parent 4ba7062 commit e580734
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/auto_moderation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func main() {
TriggerType: discordgo.AutoModerationEventTriggerKeyword,
TriggerMetadata: &discordgo.AutoModerationTriggerMetadata{
KeywordFilter: []string{"*cat*"},
RegexPatterns: []string{"(c|b)at"},
},

Enabled: &enabled,
Expand Down
4 changes: 4 additions & 0 deletions structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit e580734

Please sign in to comment.