Interface TriggerConfig
- All Superinterfaces:
SerializableData
- All Known Implementing Classes:
AbstractKeywordTriggerConfig
,AbstractTriggerConfig
,AntiSpamTriggerConfig
,CustomKeywordTriggerConfig
,MentionSpamTriggerConfig
,PresetKeywordTriggerConfig
AutoModRule
, which defines under what conditions the rule should be triggered.
Each rule is limited to a single trigger type. You can use the various factory methods on this interface to create a config.
Supported factories:
mentionSpam(int)
- Trigger on mention thresholds in messagesantiSpam()
- Trigger on spam content in messages (classified by Discord magic)keywordFilter(Collection)
/patternFilter(Collection)
- Trigger on messages containing certain keywords or regex patternspresetKeywordFilter(AutoModRule.KeywordPreset...)
- Trigger on messages containing words from predefined lists
Example
AutoModRuleData rule = AutoModRule.onMessage("Invite Links",
TriggerConfig.keywordFilter("discord.gg/*") // trigger on all invite links
.setAllowList("discord.gg/discord-api") // except certain whitelisted ones
);
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic AntiSpamTriggerConfig
antiSpam()
Trigger on spam content in messages (classified by Discord magic).getType()
The type of trigger for this config.static CustomKeywordTriggerConfig
keywordFilter
(String... keywords) Trigger on messages containing certain keywords or regex patterns.static CustomKeywordTriggerConfig
keywordFilter
(Collection<String> keywords) Trigger on messages containing certain keywords or regex patterns.static MentionSpamTriggerConfig
mentionSpam
(int mentionLimit) Trigger on mention thresholds in messages.static CustomKeywordTriggerConfig
patternFilter
(String... patterns) Trigger on messages containing certain keywords regex patterns.static CustomKeywordTriggerConfig
patternFilter
(Collection<String> patterns) Trigger on messages containing certain keywords regex patterns.static PresetKeywordTriggerConfig
Trigger on keywords from predefined lists.static PresetKeywordTriggerConfig
presetKeywordFilter
(AutoModRule.KeywordPreset... presets) Trigger on keywords from predefined lists.Methods inherited from interface net.dv8tion.jda.api.utils.data.SerializableData
toData
-
Method Details
-
getType
The type of trigger for this config.- Returns:
AutoModTriggerType
-
mentionSpam
Trigger on mention thresholds in messages.- Parameters:
mentionLimit
- The maximum number of unique mentions allowed in a message (1-50)- Returns:
MentionSpamTriggerConfig
- Throws:
IllegalArgumentException
- If the provided mention limit is not between 1 and 50
-
antiSpam
Trigger on spam content in messages (classified by Discord magic).- Returns:
AntiSpamTriggerConfig
-
keywordFilter
Trigger on messages containing certain keywords or regex patterns.
Keywords are matched case-insensitively, and may also contain whitespace.You can use wildcards at the keyword boundaries to extend the matches:
"foo*"
can match"foo"
,"foobar"
,"foo-bar"
, etc."*foo*"
can match"foo"
,"foobar"
,"barfoo"
, etc."*foo"
can match"foo"
,"barfoo"
,"bar-foo"
, etc.You can also use regex patterns using
patternFilter(Collection)
orCustomKeywordTriggerConfig.addPatterns(Collection)
.- Parameters:
keywords
- The keywords to match (case-insensitive)- Returns:
CustomKeywordTriggerConfig
- Throws:
IllegalArgumentException
-
-
keywordFilter
Trigger on messages containing certain keywords or regex patterns.
Keywords are matched case-insensitively, and may also contain whitespace.You can use wildcards at the keyword boundaries to extend the matches:
"foo*"
can match"foo"
,"foobar"
,"foo-bar"
, etc."*foo*"
can match"foo"
,"foobar"
,"barfoo"
, etc."*foo"
can match"foo"
,"barfoo"
,"bar-foo"
, etc.You can also use regex patterns using
patternFilter(String...)
orCustomKeywordTriggerConfig.addPatterns(String...)
.- Parameters:
keywords
- The keywords to match (case-insensitive)- Returns:
CustomKeywordTriggerConfig
- Throws:
IllegalArgumentException
-
-
patternFilter
Trigger on messages containing certain keywords regex patterns.
Keyword patterns are matched case-insensitively, and may also contain whitespace.Patterns may use anything supported by the rust regex crate. You can use a validator such as Rustexp to validate your pattern.
You can also use simple substring keywords using
keywordFilter(String...)
orCustomKeywordTriggerConfig.addKeywords(String...)
.- Parameters:
patterns
- The keyword patterns to match- Returns:
CustomKeywordTriggerConfig
- Throws:
IllegalArgumentException
-
-
patternFilter
Trigger on messages containing certain keywords regex patterns.
Keyword patterns are matched case-insensitively, and may also contain whitespace.Patterns may use anything supported by the rust regex crate. You can use a validator such as Rustexp to validate your pattern.
You can also use simple substring keywords using
keywordFilter(String...)
orCustomKeywordTriggerConfig.addKeywords(String...)
.- Parameters:
patterns
- The keyword patterns to match- Returns:
CustomKeywordTriggerConfig
- Throws:
IllegalArgumentException
-
-
presetKeywordFilter
@Nonnull static PresetKeywordTriggerConfig presetKeywordFilter(@Nonnull Collection<AutoModRule.KeywordPreset> presets) Trigger on keywords from predefined lists.- Parameters:
presets
- The presets to enable- Returns:
PresetKeywordTriggerConfig
- Throws:
IllegalArgumentException
- If null orAutoModRule.KeywordPreset.UNKNOWN
is provided
-
presetKeywordFilter
@Nonnull static PresetKeywordTriggerConfig presetKeywordFilter(@Nonnull AutoModRule.KeywordPreset... presets) Trigger on keywords from predefined lists.- Parameters:
presets
- The presets to enable- Returns:
PresetKeywordTriggerConfig
- Throws:
IllegalArgumentException
- If null orAutoModRule.KeywordPreset.UNKNOWN
is provided
-