-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* KeywordPresetAutoModerationRuleCreateBuilder.presets can be omitted * AutoModerationRuleCreateBuilder.buildTriggerMetadata doesn't need covariant overrides
- Loading branch information
1 parent
75caf06
commit 72a8b9e
Showing
5 changed files
with
37 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,18 +282,24 @@ public sealed interface KeywordPresetAutoModerationRuleBuilder : AllowedKeywords | |
override val triggerType: KeywordPreset get() = KeywordPreset | ||
|
||
/** The internally pre-defined wordsets which will be searched for in content. */ | ||
public val presets: MutableList<AutoModerationRuleKeywordPresetType>? | ||
public var presets: MutableList<AutoModerationRuleKeywordPresetType>? | ||
|
||
/** | ||
* Use this to set [presets][KeywordPresetAutoModerationRuleBuilder.presets] for | ||
* [KeywordPresetAutoModerationRuleBuilder]. | ||
*/ | ||
@Deprecated( | ||
"This can be replaced with 'presets', it is now a 'var'. The deprecation level will be raised to ERROR in " + | ||
"0.16.0, to HIDDEN in 0.17.0, and this declaration will be removed in 0.18.0.", | ||
ReplaceWith("this.run { [email protected] = presets }", imports = ["kotlin.run"]), | ||
DeprecationLevel.WARNING, | ||
) | ||
public fun assignPresets(presets: MutableList<AutoModerationRuleKeywordPresetType>) | ||
} | ||
|
||
/** Add a [preset] to [presets][KeywordPresetAutoModerationRuleBuilder.presets]. */ | ||
public fun KeywordPresetAutoModerationRuleBuilder.preset(preset: AutoModerationRuleKeywordPresetType) { | ||
presets?.add(preset) ?: assignPresets(mutableListOf(preset)) | ||
presets?.add(preset) ?: run { presets = mutableListOf(preset) } | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,8 +74,8 @@ public class KeywordAutoModerationRuleCreateBuilder( | |
private var _allowedKeywords: Optional<MutableList<String>> = Optional.Missing() | ||
override var allowedKeywords: MutableList<String>? by ::_allowedKeywords.delegate() | ||
|
||
// one of keywords or regexPatterns is required, don't bother to send missing trigger metadata if both are missing | ||
override fun buildTriggerMetadata(): Optional.Value<DiscordAutoModerationRuleTriggerMetadata> = | ||
// triggerMetadata is required for Keyword rules | ||
override fun buildTriggerMetadata(): Optional<DiscordAutoModerationRuleTriggerMetadata> = | ||
DiscordAutoModerationRuleTriggerMetadata( | ||
keywordFilter = _keywords.mapCopy(), | ||
regexPatterns = _regexPatterns.mapCopy(), | ||
|
@@ -97,19 +97,27 @@ public class KeywordPresetAutoModerationRuleCreateBuilder( | |
eventType: AutoModerationRuleEventType, | ||
) : AutoModerationRuleCreateBuilder(name, eventType), KeywordPresetAutoModerationRuleBuilder { | ||
|
||
override var presets: MutableList<AutoModerationRuleKeywordPresetType> = mutableListOf() | ||
private var _presets: Optional<MutableList<AutoModerationRuleKeywordPresetType>> = Optional.Missing() | ||
override var presets: MutableList<AutoModerationRuleKeywordPresetType>? by ::_presets.delegate() | ||
|
||
/** @suppress Use `this.presets = presets` instead. */ | ||
@Deprecated( | ||
"Use 'this.presets = presets' instead. The deprecation level will be raised to ERROR in 0.16.0, to HIDDEN in " + | ||
"0.17.0, and this declaration will be removed in 0.18.0.", | ||
ReplaceWith("this.run { [email protected] = presets }", imports = ["kotlin.run"]), | ||
DeprecationLevel.WARNING, | ||
) | ||
override fun assignPresets(presets: MutableList<AutoModerationRuleKeywordPresetType>) { | ||
this.presets = presets | ||
} | ||
|
||
private var _allowedKeywords: Optional<MutableList<String>> = Optional.Missing() | ||
override var allowedKeywords: MutableList<String>? by ::_allowedKeywords.delegate() | ||
|
||
override fun buildTriggerMetadata(): Optional.Value<DiscordAutoModerationRuleTriggerMetadata> = | ||
// triggerMetadata is required for KeywordPreset rules | ||
override fun buildTriggerMetadata(): Optional<DiscordAutoModerationRuleTriggerMetadata> = | ||
DiscordAutoModerationRuleTriggerMetadata( | ||
presets = presets.toList().optional(), | ||
presets = _presets.mapCopy(), | ||
allowList = _allowedKeywords.mapCopy(), | ||
).optional() | ||
} | ||
|
@@ -127,9 +135,8 @@ public class MentionSpamAutoModerationRuleCreateBuilder( | |
private var _mentionRaidProtectionEnabled: OptionalBoolean = OptionalBoolean.Missing | ||
override var mentionRaidProtectionEnabled: Boolean? by ::_mentionRaidProtectionEnabled.delegate() | ||
|
||
// one of mentionTotalLimit or mentionRaidProtectionEnabled is required, don't bother to send missing trigger | ||
// metadata if both are missing | ||
override fun buildTriggerMetadata(): Optional.Value<DiscordAutoModerationRuleTriggerMetadata> = | ||
// triggerMetadata is required for MentionSpam rules | ||
override fun buildTriggerMetadata(): Optional<DiscordAutoModerationRuleTriggerMetadata> = | ||
DiscordAutoModerationRuleTriggerMetadata( | ||
mentionTotalLimit = _mentionLimit, | ||
mentionRaidProtectionEnabled = _mentionRaidProtectionEnabled, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,7 @@ public class KeywordAutoModerationRuleModifyBuilder : | |
} | ||
|
||
/** A [SpamAutoModerationRuleBuilder] for building [AutoModerationRuleModifyRequest]s. */ | ||
@Suppress("CanSealedSubClassBeObject") // has state in super class | ||
@Suppress("CanSealedSubClassBeObject") // superclass is mutable | ||
@KordDsl | ||
public class SpamAutoModerationRuleModifyBuilder : | ||
AutoModerationRuleModifyBuilder(), | ||
|
@@ -119,6 +119,12 @@ public class KeywordPresetAutoModerationRuleModifyBuilder : | |
override var presets: MutableList<AutoModerationRuleKeywordPresetType>? by ::_presets.delegate() | ||
|
||
/** @suppress Use `this.presets = presets` instead. */ | ||
@Deprecated( | ||
"Use 'this.presets = presets' instead. The deprecation level will be raised to ERROR in 0.16.0, to HIDDEN in " + | ||
"0.17.0, and this declaration will be removed in 0.18.0.", | ||
ReplaceWith("this.run { [email protected] = presets }", imports = ["kotlin.run"]), | ||
DeprecationLevel.WARNING, | ||
) | ||
override fun assignPresets(presets: MutableList<AutoModerationRuleKeywordPresetType>) { | ||
this.presets = presets | ||
} | ||
|