From 6668dff11e61b5821fa5ed2f5e8bbb9145c93390 Mon Sep 17 00:00:00 2001 From: Luca Kellermann Date: Fri, 30 Aug 2024 23:17:06 +0200 Subject: [PATCH] Add MemberProfileAutoModerationRule The DSL for creating/editing MemberProfileAutoModerationRules looks like this: val rule = guild.createMemberProfileAutoModerationRule("name") { anywhereKeyword("cat") regexPattern("^b(a|@)d\$w(o|0)rd(s|$)") allowPrefixKeyword("black cat") blockMemberInteraction() sendAlertMessage(channelId) enabled = true } println(rule) See https://github.com/discord/discord-api-docs/pull/6040 --- common/api/common.api | 12 + common/api/common.klib.api | 6 + .../common/entity/AutoModerationActionType.kt | 7 + .../entity/AutoModerationRuleEventType.kt | 7 + .../entity/AutoModerationRuleTriggerType.kt | 7 + .../kotlin/entity/AutoModeration.kt | 9 + core/api/core.api | 47 ++++ core/api/core.klib.api | 37 +++ core/src/commonMain/kotlin/Unsafe.kt | 5 + .../kotlin/behavior/GuildBehavior.kt | 26 ++- .../AutoModerationRuleBehavior.kt | 65 +++++- .../automoderation/AutoModerationAction.kt | 12 + .../automoderation/AutoModerationRule.kt | 40 ++++ rest/api/rest.api | 75 +++++- rest/api/rest.klib.api | 75 +++++- .../AutoModerationActionBuilder.kt | 10 + .../AutoModerationRuleBuilder.kt | 214 +++++++++++++----- .../AutoModerationRuleCreateBuilder.kt | 25 ++ .../AutoModerationRuleModifyBuilder.kt | 31 ++- .../kotlin/service/AutoModerationService.kt | 21 ++ 20 files changed, 642 insertions(+), 89 deletions(-) diff --git a/common/api/common.api b/common/api/common.api index c5b3b0f34e9..d75e6459d30 100644 --- a/common/api/common.api +++ b/common/api/common.api @@ -1420,6 +1420,10 @@ public abstract class dev/kord/common/entity/AutoModerationActionType { public final fun toString ()Ljava/lang/String; } +public final class dev/kord/common/entity/AutoModerationActionType$BlockMemberInteraction : dev/kord/common/entity/AutoModerationActionType { + public static final field INSTANCE Ldev/kord/common/entity/AutoModerationActionType$BlockMemberInteraction; +} + public final class dev/kord/common/entity/AutoModerationActionType$BlockMessage : dev/kord/common/entity/AutoModerationActionType { public static final field INSTANCE Ldev/kord/common/entity/AutoModerationActionType$BlockMessage; } @@ -1456,6 +1460,10 @@ public final class dev/kord/common/entity/AutoModerationRuleEventType$Companion public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class dev/kord/common/entity/AutoModerationRuleEventType$MemberUpdate : dev/kord/common/entity/AutoModerationRuleEventType { + public static final field INSTANCE Ldev/kord/common/entity/AutoModerationRuleEventType$MemberUpdate; +} + public final class dev/kord/common/entity/AutoModerationRuleEventType$MessageSend : dev/kord/common/entity/AutoModerationRuleEventType { public static final field INSTANCE Ldev/kord/common/entity/AutoModerationRuleEventType$MessageSend; } @@ -1516,6 +1524,10 @@ public final class dev/kord/common/entity/AutoModerationRuleTriggerType$KeywordP public static final field INSTANCE Ldev/kord/common/entity/AutoModerationRuleTriggerType$KeywordPreset; } +public final class dev/kord/common/entity/AutoModerationRuleTriggerType$MemberProfile : dev/kord/common/entity/AutoModerationRuleTriggerType { + public static final field INSTANCE Ldev/kord/common/entity/AutoModerationRuleTriggerType$MemberProfile; +} + public final class dev/kord/common/entity/AutoModerationRuleTriggerType$MentionSpam : dev/kord/common/entity/AutoModerationRuleTriggerType { public static final field INSTANCE Ldev/kord/common/entity/AutoModerationRuleTriggerType$MentionSpam; } diff --git a/common/api/common.klib.api b/common/api/common.klib.api index 9308b8f8f82..26434c40600 100644 --- a/common/api/common.klib.api +++ b/common/api/common.klib.api @@ -7367,6 +7367,8 @@ sealed class dev.kord.common.entity/AutoModerationActionType { // dev.kord.commo final class Unknown : dev.kord.common.entity/AutoModerationActionType // dev.kord.common.entity/AutoModerationActionType.Unknown|null[0] + final object BlockMemberInteraction : dev.kord.common.entity/AutoModerationActionType // dev.kord.common.entity/AutoModerationActionType.BlockMemberInteraction|null[0] + final object BlockMessage : dev.kord.common.entity/AutoModerationActionType // dev.kord.common.entity/AutoModerationActionType.BlockMessage|null[0] final object Companion { // dev.kord.common.entity/AutoModerationActionType.Companion|null[0] @@ -7402,6 +7404,8 @@ sealed class dev.kord.common.entity/AutoModerationRuleEventType { // dev.kord.co final fun serializer(): kotlinx.serialization/KSerializer // dev.kord.common.entity/AutoModerationRuleEventType.Companion.serializer|serializer(){}[0] } + final object MemberUpdate : dev.kord.common.entity/AutoModerationRuleEventType // dev.kord.common.entity/AutoModerationRuleEventType.MemberUpdate|null[0] + final object MessageSend : dev.kord.common.entity/AutoModerationRuleEventType // dev.kord.common.entity/AutoModerationRuleEventType.MessageSend|null[0] } @@ -7456,6 +7460,8 @@ sealed class dev.kord.common.entity/AutoModerationRuleTriggerType { // dev.kord. final object KeywordPreset : dev.kord.common.entity/AutoModerationRuleTriggerType // dev.kord.common.entity/AutoModerationRuleTriggerType.KeywordPreset|null[0] + final object MemberProfile : dev.kord.common.entity/AutoModerationRuleTriggerType // dev.kord.common.entity/AutoModerationRuleTriggerType.MemberProfile|null[0] + final object MentionSpam : dev.kord.common.entity/AutoModerationRuleTriggerType // dev.kord.common.entity/AutoModerationRuleTriggerType.MentionSpam|null[0] final object Spam : dev.kord.common.entity/AutoModerationRuleTriggerType // dev.kord.common.entity/AutoModerationRuleTriggerType.Spam|null[0] diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationActionType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationActionType.kt index bffde5aad66..0593d80b77d 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationActionType.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationActionType.kt @@ -68,6 +68,11 @@ public sealed class AutoModerationActionType( */ public object Timeout : AutoModerationActionType(3) + /** + * Prevents a member from using text, voice, or other interactions. + */ + public object BlockMemberInteraction : AutoModerationActionType(4) + internal object Serializer : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("dev.kord.common.entity.AutoModerationActionType", @@ -90,6 +95,7 @@ public sealed class AutoModerationActionType( BlockMessage, SendAlertMessage, Timeout, + BlockMemberInteraction, ) } @@ -101,6 +107,7 @@ public sealed class AutoModerationActionType( 1 -> BlockMessage 2 -> SendAlertMessage 3 -> Timeout + 4 -> BlockMemberInteraction else -> Unknown(value) } } diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleEventType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleEventType.kt index 33fa86870f0..b2d88291deb 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleEventType.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleEventType.kt @@ -50,6 +50,11 @@ public sealed class AutoModerationRuleEventType( */ public object MessageSend : AutoModerationRuleEventType(1) + /** + * When a member edits their profile. + */ + public object MemberUpdate : AutoModerationRuleEventType(2) + internal object Serializer : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("dev.kord.common.entity.AutoModerationRuleEventType", @@ -70,6 +75,7 @@ public sealed class AutoModerationRuleEventType( public val entries: List by lazy(mode = PUBLICATION) { listOf( MessageSend, + MemberUpdate, ) } @@ -79,6 +85,7 @@ public sealed class AutoModerationRuleEventType( */ public fun from(`value`: Int): AutoModerationRuleEventType = when (value) { 1 -> MessageSend + 2 -> MemberUpdate else -> Unknown(value) } } diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleTriggerType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleTriggerType.kt index b8d04a1c652..5f53680e08f 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleTriggerType.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleTriggerType.kt @@ -65,6 +65,11 @@ public sealed class AutoModerationRuleTriggerType( */ public object MentionSpam : AutoModerationRuleTriggerType(5) + /** + * Check if member profile contains words from a user defined list of keywords. + */ + public object MemberProfile : AutoModerationRuleTriggerType(6) + internal object Serializer : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("dev.kord.common.entity.AutoModerationRuleTriggerType", @@ -88,6 +93,7 @@ public sealed class AutoModerationRuleTriggerType( Spam, KeywordPreset, MentionSpam, + MemberProfile, ) } @@ -100,6 +106,7 @@ public sealed class AutoModerationRuleTriggerType( 3 -> Spam 4 -> KeywordPreset 5 -> MentionSpam + 6 -> MemberProfile else -> Unknown(value) } } diff --git a/common/src/commonMain/kotlin/entity/AutoModeration.kt b/common/src/commonMain/kotlin/entity/AutoModeration.kt index c554d4296ec..769deb3839a 100644 --- a/common/src/commonMain/kotlin/entity/AutoModeration.kt +++ b/common/src/commonMain/kotlin/entity/AutoModeration.kt @@ -10,6 +10,10 @@ kDoc = "Check if content contains words from internal pre-defined wordsets." ), Entry("MentionSpam", intValue = 5, kDoc = "Check if content contains more unique mentions than allowed."), + Entry( + "MemberProfile", intValue = 6, + kDoc = "Check if member profile contains words from a user defined list of keywords.", + ), ], ) @@ -30,6 +34,7 @@ docUrl = "https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types", entries = [ Entry("MessageSend", intValue = 1, kDoc = "When a member sends or edits a message in the guild."), + Entry("MemberUpdate", intValue = 2, kDoc = "When a member edits their profile."), ], ) @@ -52,6 +57,10 @@ "[ModerateMembers][dev.kord.common.entity.Permission.ModerateMembers] permission is required to " + "use the [Timeout] action type." ), + Entry( + "BlockMemberInteraction", intValue = 4, + kDoc = "Prevents a member from using text, voice, or other interactions.", + ), ], ) diff --git a/core/api/core.api b/core/api/core.api index 19c163b67c2..0ec5996fce2 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -131,6 +131,7 @@ public final class dev/kord/core/Unsafe { public final fun keywordAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/behavior/automoderation/KeywordAutoModerationRuleBehavior; public final fun keywordPresetAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/behavior/automoderation/KeywordPresetAutoModerationRuleBehavior; public final fun member (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/behavior/MemberBehavior; + public final fun memberProfileAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior; public final fun mentionSpamAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/behavior/automoderation/MentionSpamAutoModerationRuleBehavior; public final fun message (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/behavior/MessageBehavior; public final fun messageChannel (Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/behavior/channel/MessageChannelBehavior; @@ -395,6 +396,8 @@ public final class dev/kord/core/behavior/GuildBehaviorKt { public static synthetic fun createKeywordPresetAutoModerationRule$default (Ldev/kord/core/behavior/GuildBehavior;Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public static final fun createMediaChannel (Ldev/kord/core/behavior/GuildBehavior;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun createMediaChannel$default (Ldev/kord/core/behavior/GuildBehavior;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static final fun createMemberProfileAutoModerationRule (Ldev/kord/core/behavior/GuildBehavior;Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun createMemberProfileAutoModerationRule$default (Ldev/kord/core/behavior/GuildBehavior;Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public static final fun createMentionSpamAutoModerationRule (Ldev/kord/core/behavior/GuildBehavior;Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun createMentionSpamAutoModerationRule$default (Ldev/kord/core/behavior/GuildBehavior;Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public static final fun createMessageCommand (Ldev/kord/core/behavior/GuildBehavior;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -879,6 +882,7 @@ public final class dev/kord/core/behavior/automoderation/AutoModerationRuleBehav public static final fun edit (Ldev/kord/core/behavior/automoderation/AutoModerationRuleBehavior;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun edit (Ldev/kord/core/behavior/automoderation/KeywordAutoModerationRuleBehavior;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun edit (Ldev/kord/core/behavior/automoderation/KeywordPresetAutoModerationRuleBehavior;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun edit (Ldev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun edit (Ldev/kord/core/behavior/automoderation/MentionSpamAutoModerationRuleBehavior;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun edit (Ldev/kord/core/behavior/automoderation/SpamAutoModerationRuleBehavior;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } @@ -919,6 +923,24 @@ public final class dev/kord/core/behavior/automoderation/KeywordPresetAutoModera public static fun getTriggerType (Ldev/kord/core/behavior/automoderation/KeywordPresetAutoModerationRuleBehavior;)Ldev/kord/common/entity/AutoModerationRuleTriggerType$KeywordPreset; } +public abstract interface class dev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior : dev/kord/core/behavior/automoderation/TypedAutoModerationRuleBehavior { + public abstract fun asAutoModerationRule (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun asAutoModerationRuleOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType$MemberProfile; + public abstract fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior; +} + +public final class dev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior$DefaultImpls { + public static fun asAutoModerationRule (Ldev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun asAutoModerationRuleOrNull (Ldev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun compareTo (Ldev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior;Ldev/kord/core/entity/Entity;)I + public static fun delete (Ldev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getGuild (Ldev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior;)Ldev/kord/core/behavior/GuildBehavior; + public static fun getGuild (Ldev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getGuildOrNull (Ldev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getTriggerType (Ldev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior;)Ldev/kord/common/entity/AutoModerationRuleTriggerType$MemberProfile; +} + public abstract interface class dev/kord/core/behavior/automoderation/MentionSpamAutoModerationRuleBehavior : dev/kord/core/behavior/automoderation/TypedAutoModerationRuleBehavior { public abstract fun asAutoModerationRule (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun asAutoModerationRuleOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -7586,6 +7608,13 @@ public final class dev/kord/core/entity/automoderation/AutoModerationRuleKt { public static synthetic fun AutoModerationRule$default (Ldev/kord/core/cache/data/AutoModerationRuleData;Ldev/kord/core/Kord;Ldev/kord/core/supplier/EntitySupplier;ILjava/lang/Object;)Ldev/kord/core/entity/automoderation/AutoModerationRule; } +public final class dev/kord/core/entity/automoderation/BlockMemberInteractionAutoModerationAction : dev/kord/core/entity/automoderation/AutoModerationAction { + public fun (Ldev/kord/core/cache/data/AutoModerationActionData;Ldev/kord/core/Kord;)V + public fun getType ()Ldev/kord/common/entity/AutoModerationActionType$BlockMemberInteraction; + public synthetic fun getType ()Ldev/kord/common/entity/AutoModerationActionType; + public fun toString ()Ljava/lang/String; +} + public final class dev/kord/core/entity/automoderation/BlockMessageAutoModerationAction : dev/kord/core/entity/automoderation/AutoModerationAction { public fun (Ldev/kord/core/cache/data/AutoModerationActionData;Ldev/kord/core/Kord;)V public final fun getCustomMessage ()Ljava/lang/String; @@ -7629,6 +7658,24 @@ public final class dev/kord/core/entity/automoderation/KeywordPresetAutoModerati public fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/automoderation/KeywordPresetAutoModerationRule; } +public final class dev/kord/core/entity/automoderation/MemberProfileAutoModerationRule : dev/kord/core/entity/automoderation/AutoModerationRule, dev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior { + public fun (Ldev/kord/core/cache/data/AutoModerationRuleData;Ldev/kord/core/Kord;Ldev/kord/core/supplier/EntitySupplier;)V + public fun asAutoModerationRule (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun asAutoModerationRuleOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getAllowedKeywords ()Ljava/util/List; + public final fun getKeywords ()Ljava/util/List; + public final fun getRegexPatterns ()Ljava/util/List; + public fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType$MemberProfile; + public synthetic fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType; + public fun toString ()Ljava/lang/String; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/automoderation/AutoModerationRuleBehavior; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/automoderation/MemberProfileAutoModerationRuleBehavior; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/automoderation/TypedAutoModerationRuleBehavior; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/Strategizable; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/automoderation/AutoModerationRule; + public fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/automoderation/MemberProfileAutoModerationRule; +} + public final class dev/kord/core/entity/automoderation/MentionSpamAutoModerationRule : dev/kord/core/entity/automoderation/AutoModerationRule, dev/kord/core/behavior/automoderation/MentionSpamAutoModerationRuleBehavior { public fun (Ldev/kord/core/cache/data/AutoModerationRuleData;Ldev/kord/core/Kord;Ldev/kord/core/supplier/EntitySupplier;)V public fun asAutoModerationRule (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; diff --git a/core/api/core.klib.api b/core/api/core.klib.api index 1d39196ab5f..0b04f2a6916 100644 --- a/core/api/core.klib.api +++ b/core/api/core.klib.api @@ -43,6 +43,15 @@ abstract interface dev.kord.core.behavior.automoderation/KeywordPresetAutoModera open suspend fun asAutoModerationRuleOrNull(): dev.kord.core.entity.automoderation/KeywordPresetAutoModerationRule? // dev.kord.core.behavior.automoderation/KeywordPresetAutoModerationRuleBehavior.asAutoModerationRuleOrNull|asAutoModerationRuleOrNull(){}[0] } +abstract interface dev.kord.core.behavior.automoderation/MemberProfileAutoModerationRuleBehavior : dev.kord.core.behavior.automoderation/TypedAutoModerationRuleBehavior { // dev.kord.core.behavior.automoderation/MemberProfileAutoModerationRuleBehavior|null[0] + open val triggerType // dev.kord.core.behavior.automoderation/MemberProfileAutoModerationRuleBehavior.triggerType|{}triggerType[0] + open fun (): dev.kord.common.entity/AutoModerationRuleTriggerType.MemberProfile // dev.kord.core.behavior.automoderation/MemberProfileAutoModerationRuleBehavior.triggerType.|(){}[0] + + abstract fun withStrategy(dev.kord.core.supplier/EntitySupplyStrategy<*>): dev.kord.core.behavior.automoderation/MemberProfileAutoModerationRuleBehavior // dev.kord.core.behavior.automoderation/MemberProfileAutoModerationRuleBehavior.withStrategy|withStrategy(dev.kord.core.supplier.EntitySupplyStrategy<*>){}[0] + open suspend fun asAutoModerationRule(): dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule // dev.kord.core.behavior.automoderation/MemberProfileAutoModerationRuleBehavior.asAutoModerationRule|asAutoModerationRule(){}[0] + open suspend fun asAutoModerationRuleOrNull(): dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule? // dev.kord.core.behavior.automoderation/MemberProfileAutoModerationRuleBehavior.asAutoModerationRuleOrNull|asAutoModerationRuleOrNull(){}[0] +} + abstract interface dev.kord.core.behavior.automoderation/MentionSpamAutoModerationRuleBehavior : dev.kord.core.behavior.automoderation/TypedAutoModerationRuleBehavior { // dev.kord.core.behavior.automoderation/MentionSpamAutoModerationRuleBehavior|null[0] open val triggerType // dev.kord.core.behavior.automoderation/MentionSpamAutoModerationRuleBehavior.triggerType|{}triggerType[0] open fun (): dev.kord.common.entity/AutoModerationRuleTriggerType.MentionSpam // dev.kord.core.behavior.automoderation/MentionSpamAutoModerationRuleBehavior.triggerType.|(){}[0] @@ -5789,6 +5798,15 @@ final class dev.kord.core.entity.application/UnknownGuildApplicationCommand : de final fun (): dev.kord.rest.service/InteractionService // dev.kord.core.entity.application/UnknownGuildApplicationCommand.service.|(){}[0] } +final class dev.kord.core.entity.automoderation/BlockMemberInteractionAutoModerationAction : dev.kord.core.entity.automoderation/AutoModerationAction { // dev.kord.core.entity.automoderation/BlockMemberInteractionAutoModerationAction|null[0] + constructor (dev.kord.core.cache.data/AutoModerationActionData, dev.kord.core/Kord) // dev.kord.core.entity.automoderation/BlockMemberInteractionAutoModerationAction.|(dev.kord.core.cache.data.AutoModerationActionData;dev.kord.core.Kord){}[0] + + final val type // dev.kord.core.entity.automoderation/BlockMemberInteractionAutoModerationAction.type|{}type[0] + final fun (): dev.kord.common.entity/AutoModerationActionType.BlockMemberInteraction // dev.kord.core.entity.automoderation/BlockMemberInteractionAutoModerationAction.type.|(){}[0] + + final fun toString(): kotlin/String // dev.kord.core.entity.automoderation/BlockMemberInteractionAutoModerationAction.toString|toString(){}[0] +} + final class dev.kord.core.entity.automoderation/BlockMessageAutoModerationAction : dev.kord.core.entity.automoderation/AutoModerationAction { // dev.kord.core.entity.automoderation/BlockMessageAutoModerationAction|null[0] constructor (dev.kord.core.cache.data/AutoModerationActionData, dev.kord.core/Kord) // dev.kord.core.entity.automoderation/BlockMessageAutoModerationAction.|(dev.kord.core.cache.data.AutoModerationActionData;dev.kord.core.Kord){}[0] @@ -5830,6 +5848,22 @@ final class dev.kord.core.entity.automoderation/KeywordPresetAutoModerationRule final suspend fun asAutoModerationRuleOrNull(): dev.kord.core.entity.automoderation/KeywordPresetAutoModerationRule // dev.kord.core.entity.automoderation/KeywordPresetAutoModerationRule.asAutoModerationRuleOrNull|asAutoModerationRuleOrNull(){}[0] } +final class dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule : dev.kord.core.behavior.automoderation/MemberProfileAutoModerationRuleBehavior, dev.kord.core.entity.automoderation/AutoModerationRule { // dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule|null[0] + constructor (dev.kord.core.cache.data/AutoModerationRuleData, dev.kord.core/Kord, dev.kord.core.supplier/EntitySupplier) // dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule.|(dev.kord.core.cache.data.AutoModerationRuleData;dev.kord.core.Kord;dev.kord.core.supplier.EntitySupplier){}[0] + + final val allowedKeywords // dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule.allowedKeywords|{}allowedKeywords[0] + final fun (): kotlin.collections/List // dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule.allowedKeywords.|(){}[0] + final val keywords // dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule.keywords|{}keywords[0] + final fun (): kotlin.collections/List // dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule.keywords.|(){}[0] + final val regexPatterns // dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule.regexPatterns|{}regexPatterns[0] + final fun (): kotlin.collections/List // dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule.regexPatterns.|(){}[0] + + final fun toString(): kotlin/String // dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule.toString|toString(){}[0] + final fun withStrategy(dev.kord.core.supplier/EntitySupplyStrategy<*>): dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule // dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule.withStrategy|withStrategy(dev.kord.core.supplier.EntitySupplyStrategy<*>){}[0] + final suspend fun asAutoModerationRule(): dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule // dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule.asAutoModerationRule|asAutoModerationRule(){}[0] + final suspend fun asAutoModerationRuleOrNull(): dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule // dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule.asAutoModerationRuleOrNull|asAutoModerationRuleOrNull(){}[0] +} + final class dev.kord.core.entity.automoderation/MentionSpamAutoModerationRule : dev.kord.core.behavior.automoderation/MentionSpamAutoModerationRuleBehavior, dev.kord.core.entity.automoderation/AutoModerationRule { // dev.kord.core.entity.automoderation/MentionSpamAutoModerationRule|null[0] constructor (dev.kord.core.cache.data/AutoModerationRuleData, dev.kord.core/Kord, dev.kord.core.supplier/EntitySupplier) // dev.kord.core.entity.automoderation/MentionSpamAutoModerationRule.|(dev.kord.core.cache.data.AutoModerationRuleData;dev.kord.core.Kord;dev.kord.core.supplier.EntitySupplier){}[0] @@ -11389,6 +11423,7 @@ final class dev.kord.core/Unsafe { // dev.kord.core/Unsafe|null[0] final fun keywordAutoModerationRule(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.behavior.automoderation/KeywordAutoModerationRuleBehavior // dev.kord.core/Unsafe.keywordAutoModerationRule|keywordAutoModerationRule(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] final fun keywordPresetAutoModerationRule(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.behavior.automoderation/KeywordPresetAutoModerationRuleBehavior // dev.kord.core/Unsafe.keywordPresetAutoModerationRule|keywordPresetAutoModerationRule(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] final fun member(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.behavior/MemberBehavior // dev.kord.core/Unsafe.member|member(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] + final fun memberProfileAutoModerationRule(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.behavior.automoderation/MemberProfileAutoModerationRuleBehavior // dev.kord.core/Unsafe.memberProfileAutoModerationRule|memberProfileAutoModerationRule(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] final fun mentionSpamAutoModerationRule(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.behavior.automoderation/MentionSpamAutoModerationRuleBehavior // dev.kord.core/Unsafe.mentionSpamAutoModerationRule|mentionSpamAutoModerationRule(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] final fun message(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.behavior/MessageBehavior // dev.kord.core/Unsafe.message|message(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] final fun messageChannel(dev.kord.common.entity/Snowflake): dev.kord.core.behavior.channel/MessageChannelBehavior // dev.kord.core/Unsafe.messageChannel|messageChannel(dev.kord.common.entity.Snowflake){}[0] @@ -12126,6 +12161,7 @@ final suspend fun <#A: dev.kord.core.behavior.channel/MessageChannelBehavior, #B final suspend inline fun (dev.kord.core.behavior.automoderation/AutoModerationRuleBehavior).dev.kord.core.behavior.automoderation/edit(kotlin/Function1): dev.kord.core.entity.automoderation/AutoModerationRule // dev.kord.core.behavior.automoderation/edit|edit@dev.kord.core.behavior.automoderation.AutoModerationRuleBehavior(kotlin.Function1){}[0] final suspend inline fun (dev.kord.core.behavior.automoderation/KeywordAutoModerationRuleBehavior).dev.kord.core.behavior.automoderation/edit(kotlin/Function1): dev.kord.core.entity.automoderation/KeywordAutoModerationRule // dev.kord.core.behavior.automoderation/edit|edit@dev.kord.core.behavior.automoderation.KeywordAutoModerationRuleBehavior(kotlin.Function1){}[0] final suspend inline fun (dev.kord.core.behavior.automoderation/KeywordPresetAutoModerationRuleBehavior).dev.kord.core.behavior.automoderation/edit(kotlin/Function1): dev.kord.core.entity.automoderation/KeywordPresetAutoModerationRule // dev.kord.core.behavior.automoderation/edit|edit@dev.kord.core.behavior.automoderation.KeywordPresetAutoModerationRuleBehavior(kotlin.Function1){}[0] +final suspend inline fun (dev.kord.core.behavior.automoderation/MemberProfileAutoModerationRuleBehavior).dev.kord.core.behavior.automoderation/edit(kotlin/Function1): dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule // dev.kord.core.behavior.automoderation/edit|edit@dev.kord.core.behavior.automoderation.MemberProfileAutoModerationRuleBehavior(kotlin.Function1){}[0] final suspend inline fun (dev.kord.core.behavior.automoderation/MentionSpamAutoModerationRuleBehavior).dev.kord.core.behavior.automoderation/edit(kotlin/Function1): dev.kord.core.entity.automoderation/MentionSpamAutoModerationRule // dev.kord.core.behavior.automoderation/edit|edit@dev.kord.core.behavior.automoderation.MentionSpamAutoModerationRuleBehavior(kotlin.Function1){}[0] final suspend inline fun (dev.kord.core.behavior.automoderation/SpamAutoModerationRuleBehavior).dev.kord.core.behavior.automoderation/edit(kotlin/Function1): dev.kord.core.entity.automoderation/SpamAutoModerationRule // dev.kord.core.behavior.automoderation/edit|edit@dev.kord.core.behavior.automoderation.SpamAutoModerationRuleBehavior(kotlin.Function1){}[0] final suspend inline fun (dev.kord.core.behavior.channel.threads/ThreadChannelBehavior).dev.kord.core.behavior.channel.threads/edit(kotlin/Function1): dev.kord.core.entity.channel.thread/ThreadChannel // dev.kord.core.behavior.channel.threads/edit|edit@dev.kord.core.behavior.channel.threads.ThreadChannelBehavior(kotlin.Function1){}[0] @@ -12179,6 +12215,7 @@ final suspend inline fun (dev.kord.core.behavior/GuildBehavior).dev.kord.core.be final suspend inline fun (dev.kord.core.behavior/GuildBehavior).dev.kord.core.behavior/createKeywordAutoModerationRule(kotlin/String, dev.kord.common.entity/AutoModerationRuleEventType = ..., kotlin/Function1): dev.kord.core.entity.automoderation/KeywordAutoModerationRule // dev.kord.core.behavior/createKeywordAutoModerationRule|createKeywordAutoModerationRule@dev.kord.core.behavior.GuildBehavior(kotlin.String;dev.kord.common.entity.AutoModerationRuleEventType;kotlin.Function1){}[0] final suspend inline fun (dev.kord.core.behavior/GuildBehavior).dev.kord.core.behavior/createKeywordPresetAutoModerationRule(kotlin/String, dev.kord.common.entity/AutoModerationRuleEventType = ..., kotlin/Function1): dev.kord.core.entity.automoderation/KeywordPresetAutoModerationRule // dev.kord.core.behavior/createKeywordPresetAutoModerationRule|createKeywordPresetAutoModerationRule@dev.kord.core.behavior.GuildBehavior(kotlin.String;dev.kord.common.entity.AutoModerationRuleEventType;kotlin.Function1){}[0] final suspend inline fun (dev.kord.core.behavior/GuildBehavior).dev.kord.core.behavior/createMediaChannel(kotlin/String, kotlin/Function1 = ...): dev.kord.core.entity.channel/MediaChannel // dev.kord.core.behavior/createMediaChannel|createMediaChannel@dev.kord.core.behavior.GuildBehavior(kotlin.String;kotlin.Function1){}[0] +final suspend inline fun (dev.kord.core.behavior/GuildBehavior).dev.kord.core.behavior/createMemberProfileAutoModerationRule(kotlin/String, dev.kord.common.entity/AutoModerationRuleEventType = ..., kotlin/Function1): dev.kord.core.entity.automoderation/MemberProfileAutoModerationRule // dev.kord.core.behavior/createMemberProfileAutoModerationRule|createMemberProfileAutoModerationRule@dev.kord.core.behavior.GuildBehavior(kotlin.String;dev.kord.common.entity.AutoModerationRuleEventType;kotlin.Function1){}[0] final suspend inline fun (dev.kord.core.behavior/GuildBehavior).dev.kord.core.behavior/createMentionSpamAutoModerationRule(kotlin/String, dev.kord.common.entity/AutoModerationRuleEventType = ..., kotlin/Function1): dev.kord.core.entity.automoderation/MentionSpamAutoModerationRule // dev.kord.core.behavior/createMentionSpamAutoModerationRule|createMentionSpamAutoModerationRule@dev.kord.core.behavior.GuildBehavior(kotlin.String;dev.kord.common.entity.AutoModerationRuleEventType;kotlin.Function1){}[0] final suspend inline fun (dev.kord.core.behavior/GuildBehavior).dev.kord.core.behavior/createMessageCommand(kotlin/String, kotlin/Function1 = ...): dev.kord.core.entity.application/GuildMessageCommand // dev.kord.core.behavior/createMessageCommand|createMessageCommand@dev.kord.core.behavior.GuildBehavior(kotlin.String;kotlin.Function1){}[0] final suspend inline fun (dev.kord.core.behavior/GuildBehavior).dev.kord.core.behavior/createNewsChannel(kotlin/String, kotlin/Function1 = ...): dev.kord.core.entity.channel/NewsChannel // dev.kord.core.behavior/createNewsChannel|createNewsChannel@dev.kord.core.behavior.GuildBehavior(kotlin.String;kotlin.Function1){}[0] diff --git a/core/src/commonMain/kotlin/Unsafe.kt b/core/src/commonMain/kotlin/Unsafe.kt index 269d0676fb5..d11f45cde83 100644 --- a/core/src/commonMain/kotlin/Unsafe.kt +++ b/core/src/commonMain/kotlin/Unsafe.kt @@ -46,6 +46,11 @@ public class Unsafe(private val kord: Kord) { ruleId: Snowflake, ): MentionSpamAutoModerationRuleBehavior = MentionSpamAutoModerationRuleBehaviorImpl(guildId, ruleId, kord) + public fun memberProfileAutoModerationRule( + guildId: Snowflake, + ruleId: Snowflake, + ): MemberProfileAutoModerationRuleBehavior = MemberProfileAutoModerationRuleBehaviorImpl(guildId, ruleId, kord) + public fun message(channelId: Snowflake, messageId: Snowflake): MessageBehavior = MessageBehavior(channelId = channelId, messageId = messageId, kord = kord) diff --git a/core/src/commonMain/kotlin/behavior/GuildBehavior.kt b/core/src/commonMain/kotlin/behavior/GuildBehavior.kt index efcb4287cd3..2a387a977c9 100644 --- a/core/src/commonMain/kotlin/behavior/GuildBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/GuildBehavior.kt @@ -3,6 +3,7 @@ package dev.kord.core.behavior import dev.kord.cache.api.query import dev.kord.common.annotation.KordExperimental import dev.kord.common.entity.* +import dev.kord.common.entity.AutoModerationRuleEventType.MemberUpdate import dev.kord.common.entity.AutoModerationRuleEventType.MessageSend import dev.kord.common.entity.Permission.ManageGuild import dev.kord.common.entity.Permission.ManageRoles @@ -34,10 +35,7 @@ import dev.kord.gateway.start import dev.kord.rest.Image import dev.kord.rest.NamedFile import dev.kord.rest.builder.auditlog.AuditLogGetRequestBuilder -import dev.kord.rest.builder.automoderation.KeywordAutoModerationRuleCreateBuilder -import dev.kord.rest.builder.automoderation.KeywordPresetAutoModerationRuleCreateBuilder -import dev.kord.rest.builder.automoderation.MentionSpamAutoModerationRuleCreateBuilder -import dev.kord.rest.builder.automoderation.SpamAutoModerationRuleCreateBuilder +import dev.kord.rest.builder.automoderation.* import dev.kord.rest.builder.ban.BanCreateBuilder import dev.kord.rest.builder.channel.* import dev.kord.rest.builder.guild.* @@ -1126,3 +1124,23 @@ public suspend inline fun GuildBehavior.createMentionSpamAutoModerationRule( val rule = kord.rest.autoModeration.createMentionSpamAutoModerationRule(guildId = id, name, eventType, builder) return MentionSpamAutoModerationRule(AutoModerationRuleData.from(rule), kord, supplier) } + +/** + * Requests to create a new [MemberProfileAutoModerationRule] in this guild and returns it. + * + * This requires the [ManageGuild] permission. + * + * @param name the rule name. + * @param eventType the rule [event type][AutoModerationRuleEventType]. + * + * @throws RestRequestException if something went wrong during the request. + */ +public suspend inline fun GuildBehavior.createMemberProfileAutoModerationRule( + name: String, + eventType: AutoModerationRuleEventType = MemberUpdate, + builder: MemberProfileAutoModerationRuleCreateBuilder.() -> Unit, +): MemberProfileAutoModerationRule { + contract { callsInPlace(builder, EXACTLY_ONCE) } + val rule = kord.rest.autoModeration.createMemberProfileAutoModerationRule(guildId = id, name, eventType, builder) + return MemberProfileAutoModerationRule(AutoModerationRuleData.from(rule), kord, supplier) +} diff --git a/core/src/commonMain/kotlin/behavior/automoderation/AutoModerationRuleBehavior.kt b/core/src/commonMain/kotlin/behavior/automoderation/AutoModerationRuleBehavior.kt index 9da181c459f..c20c83f53b8 100644 --- a/core/src/commonMain/kotlin/behavior/automoderation/AutoModerationRuleBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/automoderation/AutoModerationRuleBehavior.kt @@ -13,11 +13,11 @@ import dev.kord.core.entity.KordEntity import dev.kord.core.entity.Strategizable import dev.kord.core.entity.automoderation.* import dev.kord.core.exception.EntityNotFoundException +import dev.kord.core.hash import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.rest.builder.automoderation.* import dev.kord.rest.request.RestRequestException -import dev.kord.core.hash import kotlin.contracts.InvocationKind.EXACTLY_ONCE import kotlin.contracts.contract @@ -141,6 +141,7 @@ internal fun TypedAutoModerationRuleBehavior( Spam -> SpamAutoModerationRuleBehaviorImpl(guildId, ruleId, kord, supplier) KeywordPreset -> KeywordPresetAutoModerationRuleBehaviorImpl(guildId, ruleId, kord, supplier) MentionSpam -> MentionSpamAutoModerationRuleBehaviorImpl(guildId, ruleId, kord, supplier) + MemberProfile -> MemberProfileAutoModerationRuleBehaviorImpl(guildId, ruleId, kord, supplier) is Unknown -> UnknownAutoModerationRuleBehavior(guildId, ruleId, triggerType, kord, supplier) } @@ -392,6 +393,68 @@ public suspend inline fun MentionSpamAutoModerationRuleBehavior.edit( } +/** The behavior of a [MemberProfileAutoModerationRule]. */ +public interface MemberProfileAutoModerationRuleBehavior : TypedAutoModerationRuleBehavior { + + override val triggerType: MemberProfile get() = MemberProfile + + /** + * Requests to get this behavior as a [MemberProfileAutoModerationRule]. + * Returns `null` if it wasn't found or if the rule isn't a [MemberProfileAutoModerationRule]. + * + * This requires the [ManageGuild] permission. + * + * @throws RequestException if anything went wrong during the request. + */ + override suspend fun asAutoModerationRuleOrNull(): MemberProfileAutoModerationRule? = + super.asAutoModerationRuleOrNull() as? MemberProfileAutoModerationRule + + /** + * Requests to get this behavior as a [MemberProfileAutoModerationRule]. + * + * This requires the [ManageGuild] permission. + * + * @throws RequestException if anything went wrong during the request. + * @throws EntityNotFoundException if the [MemberProfileAutoModerationRule] wasn't found. + * @throws ClassCastException if the rule isn't a [MemberProfileAutoModerationRule]. + */ + override suspend fun asAutoModerationRule(): MemberProfileAutoModerationRule = + super.asAutoModerationRule() as MemberProfileAutoModerationRule + + override fun withStrategy(strategy: EntitySupplyStrategy<*>): MemberProfileAutoModerationRuleBehavior +} + +internal class MemberProfileAutoModerationRuleBehaviorImpl( + override val guildId: Snowflake, + override val id: Snowflake, + override val kord: Kord, + override val supplier: EntitySupplier = kord.defaultSupplier, +) : MemberProfileAutoModerationRuleBehavior { + override fun withStrategy(strategy: EntitySupplyStrategy<*>) = + MemberProfileAutoModerationRuleBehaviorImpl(guildId, id, kord, strategy.supply(kord)) + + override fun equals(other: Any?) = autoModerationRuleEquals(other) + override fun hashCode() = autoModerationRuleHashCode() + override fun toString() = + "MemberProfileAutoModerationRuleBehavior(guildId=$guildId, id=$id, kord=$kord, supplier=$supplier)" +} + +/** + * Requests to edit this [MemberProfileAutoModerationRule] and returns the edited rule. + * + * This requires the [ManageGuild] permission. + * + * @throws RestRequestException if something went wrong during the request. + */ +public suspend inline fun MemberProfileAutoModerationRuleBehavior.edit( + builder: MemberProfileAutoModerationRuleModifyBuilder.() -> Unit, +): MemberProfileAutoModerationRule { + contract { callsInPlace(builder, EXACTLY_ONCE) } + val rule = kord.rest.autoModeration.modifyMemberProfileAutoModerationRule(guildId, ruleId = id, builder) + return MemberProfileAutoModerationRule(AutoModerationRuleData.from(rule), kord, supplier) +} + + private class UnknownAutoModerationRuleBehavior( override val guildId: Snowflake, override val id: Snowflake, diff --git a/core/src/commonMain/kotlin/entity/automoderation/AutoModerationAction.kt b/core/src/commonMain/kotlin/entity/automoderation/AutoModerationAction.kt index 368943967e3..cbba11bb8d0 100644 --- a/core/src/commonMain/kotlin/entity/automoderation/AutoModerationAction.kt +++ b/core/src/commonMain/kotlin/entity/automoderation/AutoModerationAction.kt @@ -34,6 +34,7 @@ internal fun AutoModerationAction(data: AutoModerationActionData, kord: Kord) = BlockMessage -> BlockMessageAutoModerationAction(data, kord) SendAlertMessage -> SendAlertMessageAutoModerationAction(data, kord) Timeout -> TimeoutAutoModerationAction(data, kord) + BlockMemberInteraction -> BlockMemberInteractionAutoModerationAction(data, kord) is Unknown -> UnknownAutoModerationAction(data, kord) } @@ -79,6 +80,17 @@ public class TimeoutAutoModerationAction( override fun toString(): String = "TimeoutAutoModerationAction(data=$data)" } +/** An [AutoModerationAction] of type [BlockMemberInteraction]. */ +public class BlockMemberInteractionAutoModerationAction( + data: AutoModerationActionData, + kord: Kord, +) : AutoModerationAction(data, kord, expectedActionType = BlockMemberInteraction) { + + override val type: BlockMemberInteraction get() = BlockMemberInteraction + + override fun toString(): String = "BlockMemberInteractionAutoModerationAction(data=$data)" +} + /** An [AutoModerationAction] of type [Unknown]. */ public class UnknownAutoModerationAction( data: AutoModerationActionData, diff --git a/core/src/commonMain/kotlin/entity/automoderation/AutoModerationRule.kt b/core/src/commonMain/kotlin/entity/automoderation/AutoModerationRule.kt index 7b22b0c193f..f7fd9384bcc 100644 --- a/core/src/commonMain/kotlin/entity/automoderation/AutoModerationRule.kt +++ b/core/src/commonMain/kotlin/entity/automoderation/AutoModerationRule.kt @@ -110,6 +110,7 @@ internal fun AutoModerationRule( Spam -> SpamAutoModerationRule(data, kord, supplier) KeywordPreset -> KeywordPresetAutoModerationRule(data, kord, supplier) MentionSpam -> MentionSpamAutoModerationRule(data, kord, supplier) + MemberProfile -> MemberProfileAutoModerationRule(data, kord, supplier) is Unknown -> UnknownAutoModerationRule(data, kord, supplier) } @@ -213,6 +214,45 @@ public class MentionSpamAutoModerationRule(data: AutoModerationRuleData, kord: K override fun toString(): String = "MentionSpamAutoModerationRule(data=$data, kord=$kord, supplier=$supplier)" } +/** An [AutoModerationRule] with trigger type [MemberProfile]. */ +public class MemberProfileAutoModerationRule(data: AutoModerationRuleData, kord: Kord, supplier: EntitySupplier) : + AutoModerationRule(data, kord, supplier, expectedTriggerType = MemberProfile), + MemberProfileAutoModerationRuleBehavior { + + /** + * Substrings which will be searched for in content. + * + * A keyword can be a phrase which contains multiple words. + * [Wildcard symbols](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) + * can be used to customize how each keyword will be matched. + */ + public val keywords: List get() = data.triggerMetadata.keywordFilter.orEmpty() + + /** + * Regular expression patterns which will be matched against content. + * + * Only Rust flavored regex is currently supported. + */ + public val regexPatterns: List get() = data.triggerMetadata.regexPatterns.orEmpty() + + /** + * Substrings which should not trigger the rule. + * + * A keyword can be a phrase which contains multiple words. + * [Wildcard symbols](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) + * can be used to customize how each keyword will be matched. + */ + public val allowedKeywords: List get() = data.triggerMetadata.allowList.orEmpty() + + override suspend fun asAutoModerationRuleOrNull(): MemberProfileAutoModerationRule = this + override suspend fun asAutoModerationRule(): MemberProfileAutoModerationRule = this + + override fun withStrategy(strategy: EntitySupplyStrategy<*>): MemberProfileAutoModerationRule = + MemberProfileAutoModerationRule(data, kord, strategy.supply(kord)) + + override fun toString(): String = "MemberProfileAutoModerationRule(data=$data, kord=$kord, supplier=$supplier)" +} + /** An [AutoModerationRule] with trigger type [Unknown]. */ public class UnknownAutoModerationRule(data: AutoModerationRuleData, kord: Kord, supplier: EntitySupplier) : AutoModerationRule(data, kord, supplier, expectedTriggerType = null) { diff --git a/rest/api/rest.api b/rest/api/rest.api index 1b0fc4f685c..5e867872f8f 100644 --- a/rest/api/rest.api +++ b/rest/api/rest.api @@ -162,18 +162,27 @@ public final class dev/kord/rest/builder/automoderation/AutoModerationRuleBuilde public static final fun allowKeyword (Ldev/kord/rest/builder/automoderation/AllowedKeywordsAutoModerationRuleBuilder;Ljava/lang/String;)V public static final fun allowPrefixKeyword (Ldev/kord/rest/builder/automoderation/AllowedKeywordsAutoModerationRuleBuilder;Ljava/lang/String;)V public static final fun allowSuffixKeyword (Ldev/kord/rest/builder/automoderation/AllowedKeywordsAutoModerationRuleBuilder;Ljava/lang/String;)V - public static final fun anywhereKeyword (Ldev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder;Ljava/lang/String;)V + public static final fun anywhereKeyword (Ldev/kord/rest/builder/automoderation/FilteredKeywordsAutoModerationRuleBuilder;Ljava/lang/String;)V + public static final synthetic fun anywhereKeyword (Ldev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder;Ljava/lang/String;)V + public static final fun blockMemberInteraction (Ldev/kord/rest/builder/automoderation/MemberProfileAutoModerationRuleBuilder;Lkotlin/jvm/functions/Function1;)V + public static synthetic fun blockMemberInteraction$default (Ldev/kord/rest/builder/automoderation/MemberProfileAutoModerationRuleBuilder;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V public static final fun blockMessage (Ldev/kord/rest/builder/automoderation/AutoModerationRuleBuilder;Lkotlin/jvm/functions/Function1;)V + public static final fun blockMessage (Ldev/kord/rest/builder/automoderation/BlockMessageAutoModerationRuleBuilder;Lkotlin/jvm/functions/Function1;)V public static synthetic fun blockMessage$default (Ldev/kord/rest/builder/automoderation/AutoModerationRuleBuilder;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V + public static synthetic fun blockMessage$default (Ldev/kord/rest/builder/automoderation/BlockMessageAutoModerationRuleBuilder;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V public static final fun exemptChannel (Ldev/kord/rest/builder/automoderation/AutoModerationRuleBuilder;Ldev/kord/common/entity/Snowflake;)V public static final fun exemptRole (Ldev/kord/rest/builder/automoderation/AutoModerationRuleBuilder;Ldev/kord/common/entity/Snowflake;)V - public static final fun keyword (Ldev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder;Ljava/lang/String;)V - public static final fun prefixKeyword (Ldev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder;Ljava/lang/String;)V + public static final fun keyword (Ldev/kord/rest/builder/automoderation/FilteredKeywordsAutoModerationRuleBuilder;Ljava/lang/String;)V + public static final synthetic fun keyword (Ldev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder;Ljava/lang/String;)V + public static final fun prefixKeyword (Ldev/kord/rest/builder/automoderation/FilteredKeywordsAutoModerationRuleBuilder;Ljava/lang/String;)V + public static final synthetic fun prefixKeyword (Ldev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder;Ljava/lang/String;)V public static final fun preset (Ldev/kord/rest/builder/automoderation/KeywordPresetAutoModerationRuleBuilder;Ldev/kord/common/entity/AutoModerationRuleKeywordPresetType;)V - public static final fun regexPattern (Ldev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder;Ljava/lang/String;)V + public static final fun regexPattern (Ldev/kord/rest/builder/automoderation/FilteredKeywordsAutoModerationRuleBuilder;Ljava/lang/String;)V + public static final synthetic fun regexPattern (Ldev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder;Ljava/lang/String;)V public static final fun sendAlertMessage (Ldev/kord/rest/builder/automoderation/AutoModerationRuleBuilder;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;)V public static synthetic fun sendAlertMessage$default (Ldev/kord/rest/builder/automoderation/AutoModerationRuleBuilder;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V - public static final fun suffixKeyword (Ldev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder;Ljava/lang/String;)V + public static final fun suffixKeyword (Ldev/kord/rest/builder/automoderation/FilteredKeywordsAutoModerationRuleBuilder;Ljava/lang/String;)V + public static final synthetic fun suffixKeyword (Ldev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder;Ljava/lang/String;)V public static final fun timeout-8Mi8wO0 (Ldev/kord/rest/builder/automoderation/TimeoutAutoModerationRuleBuilder;JLkotlin/jvm/functions/Function1;)V public static synthetic fun timeout-8Mi8wO0$default (Ldev/kord/rest/builder/automoderation/TimeoutAutoModerationRuleBuilder;JLkotlin/jvm/functions/Function1;ILjava/lang/Object;)V } @@ -225,6 +234,12 @@ public abstract class dev/kord/rest/builder/automoderation/AutoModerationRuleMod public synthetic fun toRequest ()Ljava/lang/Object; } +public final class dev/kord/rest/builder/automoderation/BlockMemberInteractionAutoModerationActionBuilder : dev/kord/rest/builder/automoderation/AutoModerationActionBuilder { + public fun ()V + public fun getType ()Ldev/kord/common/entity/AutoModerationActionType$BlockMemberInteraction; + public synthetic fun getType ()Ldev/kord/common/entity/AutoModerationActionType; +} + public final class dev/kord/rest/builder/automoderation/BlockMessageAutoModerationActionBuilder : dev/kord/rest/builder/automoderation/AutoModerationActionBuilder { public fun ()V public final fun getCustomMessage ()Ljava/lang/String; @@ -233,14 +248,20 @@ public final class dev/kord/rest/builder/automoderation/BlockMessageAutoModerati public final fun setCustomMessage (Ljava/lang/String;)V } -public abstract interface class dev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder : dev/kord/rest/builder/automoderation/AllowedKeywordsAutoModerationRuleBuilder, dev/kord/rest/builder/automoderation/TimeoutAutoModerationRuleBuilder { +public abstract interface class dev/kord/rest/builder/automoderation/BlockMessageAutoModerationRuleBuilder : dev/kord/rest/builder/automoderation/TypedAutoModerationRuleBuilder { +} + +public abstract interface class dev/kord/rest/builder/automoderation/FilteredKeywordsAutoModerationRuleBuilder : dev/kord/rest/builder/automoderation/TypedAutoModerationRuleBuilder { public abstract fun getKeywords ()Ljava/util/List; public abstract fun getRegexPatterns ()Ljava/util/List; - public abstract fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType$Keyword; public abstract fun setKeywords (Ljava/util/List;)V public abstract fun setRegexPatterns (Ljava/util/List;)V } +public abstract interface class dev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder : dev/kord/rest/builder/automoderation/AllowedKeywordsAutoModerationRuleBuilder, dev/kord/rest/builder/automoderation/BlockMessageAutoModerationRuleBuilder, dev/kord/rest/builder/automoderation/FilteredKeywordsAutoModerationRuleBuilder, dev/kord/rest/builder/automoderation/TimeoutAutoModerationRuleBuilder { + public abstract fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType$Keyword; +} + public final class dev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder$DefaultImpls { public static fun getTriggerType (Ldev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder;)Ldev/kord/common/entity/AutoModerationRuleTriggerType$Keyword; } @@ -270,7 +291,7 @@ public final class dev/kord/rest/builder/automoderation/KeywordAutoModerationRul public fun setRegexPatterns (Ljava/util/List;)V } -public abstract interface class dev/kord/rest/builder/automoderation/KeywordPresetAutoModerationRuleBuilder : dev/kord/rest/builder/automoderation/AllowedKeywordsAutoModerationRuleBuilder { +public abstract interface class dev/kord/rest/builder/automoderation/KeywordPresetAutoModerationRuleBuilder : dev/kord/rest/builder/automoderation/AllowedKeywordsAutoModerationRuleBuilder, dev/kord/rest/builder/automoderation/BlockMessageAutoModerationRuleBuilder { public abstract fun assignPresets (Ljava/util/List;)V public abstract fun getPresets ()Ljava/util/List; public abstract fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType$KeywordPreset; @@ -303,7 +324,39 @@ public final class dev/kord/rest/builder/automoderation/KeywordPresetAutoModerat public fun setPresets (Ljava/util/List;)V } -public abstract interface class dev/kord/rest/builder/automoderation/MentionSpamAutoModerationRuleBuilder : dev/kord/rest/builder/automoderation/TimeoutAutoModerationRuleBuilder { +public abstract interface class dev/kord/rest/builder/automoderation/MemberProfileAutoModerationRuleBuilder : dev/kord/rest/builder/automoderation/AllowedKeywordsAutoModerationRuleBuilder, dev/kord/rest/builder/automoderation/FilteredKeywordsAutoModerationRuleBuilder { + public abstract fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType$MemberProfile; +} + +public final class dev/kord/rest/builder/automoderation/MemberProfileAutoModerationRuleBuilder$DefaultImpls { + public static fun getTriggerType (Ldev/kord/rest/builder/automoderation/MemberProfileAutoModerationRuleBuilder;)Ldev/kord/common/entity/AutoModerationRuleTriggerType$MemberProfile; +} + +public final class dev/kord/rest/builder/automoderation/MemberProfileAutoModerationRuleCreateBuilder : dev/kord/rest/builder/automoderation/AutoModerationRuleCreateBuilder, dev/kord/rest/builder/automoderation/MemberProfileAutoModerationRuleBuilder { + public fun (Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;)V + public fun getAllowedKeywords ()Ljava/util/List; + public fun getKeywords ()Ljava/util/List; + public fun getRegexPatterns ()Ljava/util/List; + public fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType$MemberProfile; + public synthetic fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType; + public fun setAllowedKeywords (Ljava/util/List;)V + public fun setKeywords (Ljava/util/List;)V + public fun setRegexPatterns (Ljava/util/List;)V +} + +public final class dev/kord/rest/builder/automoderation/MemberProfileAutoModerationRuleModifyBuilder : dev/kord/rest/builder/automoderation/AutoModerationRuleModifyBuilder, dev/kord/rest/builder/automoderation/MemberProfileAutoModerationRuleBuilder { + public fun ()V + public fun getAllowedKeywords ()Ljava/util/List; + public fun getKeywords ()Ljava/util/List; + public fun getRegexPatterns ()Ljava/util/List; + public fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType$MemberProfile; + public synthetic fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType; + public fun setAllowedKeywords (Ljava/util/List;)V + public fun setKeywords (Ljava/util/List;)V + public fun setRegexPatterns (Ljava/util/List;)V +} + +public abstract interface class dev/kord/rest/builder/automoderation/MentionSpamAutoModerationRuleBuilder : dev/kord/rest/builder/automoderation/BlockMessageAutoModerationRuleBuilder, dev/kord/rest/builder/automoderation/TimeoutAutoModerationRuleBuilder { public abstract fun getMentionLimit ()Ljava/lang/Integer; public abstract fun getMentionRaidProtectionEnabled ()Ljava/lang/Boolean; public abstract fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType$MentionSpam; @@ -345,7 +398,7 @@ public final class dev/kord/rest/builder/automoderation/SendAlertMessageAutoMode public final fun setChannelId (Ldev/kord/common/entity/Snowflake;)V } -public abstract interface class dev/kord/rest/builder/automoderation/SpamAutoModerationRuleBuilder : dev/kord/rest/builder/automoderation/TypedAutoModerationRuleBuilder { +public abstract interface class dev/kord/rest/builder/automoderation/SpamAutoModerationRuleBuilder : dev/kord/rest/builder/automoderation/BlockMessageAutoModerationRuleBuilder { public abstract fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType$Spam; } @@ -7138,6 +7191,7 @@ public final class dev/kord/rest/service/AutoModerationService : dev/kord/rest/s public static synthetic fun createAutoModerationRule$default (Ldev/kord/rest/service/AutoModerationService;Ldev/kord/common/entity/Snowflake;Ldev/kord/rest/json/request/AutoModerationRuleCreateRequest;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public final fun createKeywordAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun createKeywordPresetAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun createMemberProfileAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun createMentionSpamAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun createSpamAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun deleteAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -7148,6 +7202,7 @@ public final class dev/kord/rest/service/AutoModerationService : dev/kord/rest/s public static synthetic fun modifyAutoModerationRule$default (Ldev/kord/rest/service/AutoModerationService;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/rest/json/request/AutoModerationRuleModifyRequest;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public final fun modifyKeywordAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun modifyKeywordPresetAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun modifyMemberProfileAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun modifyMentionSpamAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun modifySpamAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun modifyUntypedAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; diff --git a/rest/api/rest.klib.api b/rest/api/rest.klib.api index 5a0bc4b8049..e87c8d57004 100644 --- a/rest/api/rest.klib.api +++ b/rest/api/rest.klib.api @@ -447,19 +447,23 @@ sealed interface dev.kord.rest.builder.automoderation/AutoModerationRuleBuilder abstract fun assignName(kotlin/String) // dev.kord.rest.builder.automoderation/AutoModerationRuleBuilder.assignName|assignName(kotlin.String){}[0] } -sealed interface dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder : dev.kord.rest.builder.automoderation/AllowedKeywordsAutoModerationRuleBuilder, dev.kord.rest.builder.automoderation/TimeoutAutoModerationRuleBuilder { // dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder|null[0] +sealed interface dev.kord.rest.builder.automoderation/BlockMessageAutoModerationRuleBuilder : dev.kord.rest.builder.automoderation/TypedAutoModerationRuleBuilder // dev.kord.rest.builder.automoderation/BlockMessageAutoModerationRuleBuilder|null[0] + +sealed interface dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder : dev.kord.rest.builder.automoderation/TypedAutoModerationRuleBuilder { // dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder|null[0] + abstract var keywords // dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder.keywords|{}keywords[0] + abstract fun (): kotlin.collections/MutableList? // dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder.keywords.|(){}[0] + abstract fun (kotlin.collections/MutableList?) // dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder.keywords.|(kotlin.collections.MutableList?){}[0] + abstract var regexPatterns // dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder.regexPatterns|{}regexPatterns[0] + abstract fun (): kotlin.collections/MutableList? // dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder.regexPatterns.|(){}[0] + abstract fun (kotlin.collections/MutableList?) // dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder.regexPatterns.|(kotlin.collections.MutableList?){}[0] +} + +sealed interface dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder : dev.kord.rest.builder.automoderation/AllowedKeywordsAutoModerationRuleBuilder, dev.kord.rest.builder.automoderation/BlockMessageAutoModerationRuleBuilder, dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder, dev.kord.rest.builder.automoderation/TimeoutAutoModerationRuleBuilder { // dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder|null[0] open val triggerType // dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder.triggerType|{}triggerType[0] open fun (): dev.kord.common.entity/AutoModerationRuleTriggerType.Keyword // dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder.triggerType.|(){}[0] - - abstract var keywords // dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder.keywords|{}keywords[0] - abstract fun (): kotlin.collections/MutableList? // dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder.keywords.|(){}[0] - abstract fun (kotlin.collections/MutableList?) // dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder.keywords.|(kotlin.collections.MutableList?){}[0] - abstract var regexPatterns // dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder.regexPatterns|{}regexPatterns[0] - abstract fun (): kotlin.collections/MutableList? // dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder.regexPatterns.|(){}[0] - abstract fun (kotlin.collections/MutableList?) // dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder.regexPatterns.|(kotlin.collections.MutableList?){}[0] } -sealed interface dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder : dev.kord.rest.builder.automoderation/AllowedKeywordsAutoModerationRuleBuilder { // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder|null[0] +sealed interface dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder : dev.kord.rest.builder.automoderation/AllowedKeywordsAutoModerationRuleBuilder, dev.kord.rest.builder.automoderation/BlockMessageAutoModerationRuleBuilder { // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder|null[0] abstract val presets // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder.presets|{}presets[0] abstract fun (): kotlin.collections/MutableList? // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder.presets.|(){}[0] open val triggerType // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder.triggerType|{}triggerType[0] @@ -468,7 +472,12 @@ sealed interface dev.kord.rest.builder.automoderation/KeywordPresetAutoModeratio abstract fun assignPresets(kotlin.collections/MutableList) // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder.assignPresets|assignPresets(kotlin.collections.MutableList){}[0] } -sealed interface dev.kord.rest.builder.automoderation/MentionSpamAutoModerationRuleBuilder : dev.kord.rest.builder.automoderation/TimeoutAutoModerationRuleBuilder { // dev.kord.rest.builder.automoderation/MentionSpamAutoModerationRuleBuilder|null[0] +sealed interface dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleBuilder : dev.kord.rest.builder.automoderation/AllowedKeywordsAutoModerationRuleBuilder, dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder { // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleBuilder|null[0] + open val triggerType // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleBuilder.triggerType|{}triggerType[0] + open fun (): dev.kord.common.entity/AutoModerationRuleTriggerType.MemberProfile // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleBuilder.triggerType.|(){}[0] +} + +sealed interface dev.kord.rest.builder.automoderation/MentionSpamAutoModerationRuleBuilder : dev.kord.rest.builder.automoderation/BlockMessageAutoModerationRuleBuilder, dev.kord.rest.builder.automoderation/TimeoutAutoModerationRuleBuilder { // dev.kord.rest.builder.automoderation/MentionSpamAutoModerationRuleBuilder|null[0] open val triggerType // dev.kord.rest.builder.automoderation/MentionSpamAutoModerationRuleBuilder.triggerType|{}triggerType[0] open fun (): dev.kord.common.entity/AutoModerationRuleTriggerType.MentionSpam // dev.kord.rest.builder.automoderation/MentionSpamAutoModerationRuleBuilder.triggerType.|(){}[0] @@ -480,7 +489,7 @@ sealed interface dev.kord.rest.builder.automoderation/MentionSpamAutoModerationR abstract fun (kotlin/Boolean?) // dev.kord.rest.builder.automoderation/MentionSpamAutoModerationRuleBuilder.mentionRaidProtectionEnabled.|(kotlin.Boolean?){}[0] } -sealed interface dev.kord.rest.builder.automoderation/SpamAutoModerationRuleBuilder : dev.kord.rest.builder.automoderation/TypedAutoModerationRuleBuilder { // dev.kord.rest.builder.automoderation/SpamAutoModerationRuleBuilder|null[0] +sealed interface dev.kord.rest.builder.automoderation/SpamAutoModerationRuleBuilder : dev.kord.rest.builder.automoderation/BlockMessageAutoModerationRuleBuilder { // dev.kord.rest.builder.automoderation/SpamAutoModerationRuleBuilder|null[0] open val triggerType // dev.kord.rest.builder.automoderation/SpamAutoModerationRuleBuilder.triggerType|{}triggerType[0] open fun (): dev.kord.common.entity/AutoModerationRuleTriggerType.Spam // dev.kord.rest.builder.automoderation/SpamAutoModerationRuleBuilder.triggerType.|(){}[0] } @@ -719,6 +728,13 @@ final class dev.kord.rest.builder.auditlog/AuditLogGetRequestBuilder : dev.kord. final fun toRequest(): dev.kord.rest.json.request/AuditLogGetRequest // dev.kord.rest.builder.auditlog/AuditLogGetRequestBuilder.toRequest|toRequest(){}[0] } +final class dev.kord.rest.builder.automoderation/BlockMemberInteractionAutoModerationActionBuilder : dev.kord.rest.builder.automoderation/AutoModerationActionBuilder { // dev.kord.rest.builder.automoderation/BlockMemberInteractionAutoModerationActionBuilder|null[0] + constructor () // dev.kord.rest.builder.automoderation/BlockMemberInteractionAutoModerationActionBuilder.|(){}[0] + + final val type // dev.kord.rest.builder.automoderation/BlockMemberInteractionAutoModerationActionBuilder.type|{}type[0] + final fun (): dev.kord.common.entity/AutoModerationActionType.BlockMemberInteraction // dev.kord.rest.builder.automoderation/BlockMemberInteractionAutoModerationActionBuilder.type.|(){}[0] +} + final class dev.kord.rest.builder.automoderation/BlockMessageAutoModerationActionBuilder : dev.kord.rest.builder.automoderation/AutoModerationActionBuilder { // dev.kord.rest.builder.automoderation/BlockMessageAutoModerationActionBuilder|null[0] constructor () // dev.kord.rest.builder.automoderation/BlockMessageAutoModerationActionBuilder.|(){}[0] @@ -784,6 +800,34 @@ final class dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRule final fun assignPresets(kotlin.collections/MutableList) // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleModifyBuilder.assignPresets|assignPresets(kotlin.collections.MutableList){}[0] } +final class dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleCreateBuilder : dev.kord.rest.builder.automoderation/AutoModerationRuleCreateBuilder, dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleBuilder { // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleCreateBuilder|null[0] + constructor (kotlin/String, dev.kord.common.entity/AutoModerationRuleEventType) // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleCreateBuilder.|(kotlin.String;dev.kord.common.entity.AutoModerationRuleEventType){}[0] + + final var allowedKeywords // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleCreateBuilder.allowedKeywords|{}allowedKeywords[0] + final fun (): kotlin.collections/MutableList? // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleCreateBuilder.allowedKeywords.|(){}[0] + final fun (kotlin.collections/MutableList?) // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleCreateBuilder.allowedKeywords.|(kotlin.collections.MutableList?){}[0] + final var keywords // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleCreateBuilder.keywords|{}keywords[0] + final fun (): kotlin.collections/MutableList? // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleCreateBuilder.keywords.|(){}[0] + final fun (kotlin.collections/MutableList?) // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleCreateBuilder.keywords.|(kotlin.collections.MutableList?){}[0] + final var regexPatterns // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleCreateBuilder.regexPatterns|{}regexPatterns[0] + final fun (): kotlin.collections/MutableList? // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleCreateBuilder.regexPatterns.|(){}[0] + final fun (kotlin.collections/MutableList?) // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleCreateBuilder.regexPatterns.|(kotlin.collections.MutableList?){}[0] +} + +final class dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleModifyBuilder : dev.kord.rest.builder.automoderation/AutoModerationRuleModifyBuilder, dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleBuilder { // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleModifyBuilder|null[0] + constructor () // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleModifyBuilder.|(){}[0] + + final var allowedKeywords // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleModifyBuilder.allowedKeywords|{}allowedKeywords[0] + final fun (): kotlin.collections/MutableList? // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleModifyBuilder.allowedKeywords.|(){}[0] + final fun (kotlin.collections/MutableList?) // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleModifyBuilder.allowedKeywords.|(kotlin.collections.MutableList?){}[0] + final var keywords // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleModifyBuilder.keywords|{}keywords[0] + final fun (): kotlin.collections/MutableList? // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleModifyBuilder.keywords.|(){}[0] + final fun (kotlin.collections/MutableList?) // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleModifyBuilder.keywords.|(kotlin.collections.MutableList?){}[0] + final var regexPatterns // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleModifyBuilder.regexPatterns|{}regexPatterns[0] + final fun (): kotlin.collections/MutableList? // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleModifyBuilder.regexPatterns.|(){}[0] + final fun (kotlin.collections/MutableList?) // dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleModifyBuilder.regexPatterns.|(kotlin.collections.MutableList?){}[0] +} + final class dev.kord.rest.builder.automoderation/MentionSpamAutoModerationRuleCreateBuilder : dev.kord.rest.builder.automoderation/AutoModerationRuleCreateBuilder, dev.kord.rest.builder.automoderation/MentionSpamAutoModerationRuleBuilder { // dev.kord.rest.builder.automoderation/MentionSpamAutoModerationRuleCreateBuilder|null[0] constructor (kotlin/String, dev.kord.common.entity/AutoModerationRuleEventType) // dev.kord.rest.builder.automoderation/MentionSpamAutoModerationRuleCreateBuilder.|(kotlin.String;dev.kord.common.entity.AutoModerationRuleEventType){}[0] @@ -6536,10 +6580,12 @@ final class dev.kord.rest.service/AutoModerationService : dev.kord.rest.service/ final suspend fun modifyAutoModerationRule(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake, dev.kord.rest.json.request/AutoModerationRuleModifyRequest, kotlin/String? = ...): dev.kord.common.entity/DiscordAutoModerationRule // dev.kord.rest.service/AutoModerationService.modifyAutoModerationRule|modifyAutoModerationRule(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake;dev.kord.rest.json.request.AutoModerationRuleModifyRequest;kotlin.String?){}[0] final suspend inline fun createKeywordAutoModerationRule(dev.kord.common.entity/Snowflake, kotlin/String, dev.kord.common.entity/AutoModerationRuleEventType, kotlin/Function1): dev.kord.common.entity/DiscordAutoModerationRule // dev.kord.rest.service/AutoModerationService.createKeywordAutoModerationRule|createKeywordAutoModerationRule(dev.kord.common.entity.Snowflake;kotlin.String;dev.kord.common.entity.AutoModerationRuleEventType;kotlin.Function1){}[0] final suspend inline fun createKeywordPresetAutoModerationRule(dev.kord.common.entity/Snowflake, kotlin/String, dev.kord.common.entity/AutoModerationRuleEventType, kotlin/Function1): dev.kord.common.entity/DiscordAutoModerationRule // dev.kord.rest.service/AutoModerationService.createKeywordPresetAutoModerationRule|createKeywordPresetAutoModerationRule(dev.kord.common.entity.Snowflake;kotlin.String;dev.kord.common.entity.AutoModerationRuleEventType;kotlin.Function1){}[0] + final suspend inline fun createMemberProfileAutoModerationRule(dev.kord.common.entity/Snowflake, kotlin/String, dev.kord.common.entity/AutoModerationRuleEventType, kotlin/Function1): dev.kord.common.entity/DiscordAutoModerationRule // dev.kord.rest.service/AutoModerationService.createMemberProfileAutoModerationRule|createMemberProfileAutoModerationRule(dev.kord.common.entity.Snowflake;kotlin.String;dev.kord.common.entity.AutoModerationRuleEventType;kotlin.Function1){}[0] final suspend inline fun createMentionSpamAutoModerationRule(dev.kord.common.entity/Snowflake, kotlin/String, dev.kord.common.entity/AutoModerationRuleEventType, kotlin/Function1): dev.kord.common.entity/DiscordAutoModerationRule // dev.kord.rest.service/AutoModerationService.createMentionSpamAutoModerationRule|createMentionSpamAutoModerationRule(dev.kord.common.entity.Snowflake;kotlin.String;dev.kord.common.entity.AutoModerationRuleEventType;kotlin.Function1){}[0] final suspend inline fun createSpamAutoModerationRule(dev.kord.common.entity/Snowflake, kotlin/String, dev.kord.common.entity/AutoModerationRuleEventType, kotlin/Function1): dev.kord.common.entity/DiscordAutoModerationRule // dev.kord.rest.service/AutoModerationService.createSpamAutoModerationRule|createSpamAutoModerationRule(dev.kord.common.entity.Snowflake;kotlin.String;dev.kord.common.entity.AutoModerationRuleEventType;kotlin.Function1){}[0] final suspend inline fun modifyKeywordAutoModerationRule(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake, kotlin/Function1): dev.kord.common.entity/DiscordAutoModerationRule // dev.kord.rest.service/AutoModerationService.modifyKeywordAutoModerationRule|modifyKeywordAutoModerationRule(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake;kotlin.Function1){}[0] final suspend inline fun modifyKeywordPresetAutoModerationRule(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake, kotlin/Function1): dev.kord.common.entity/DiscordAutoModerationRule // dev.kord.rest.service/AutoModerationService.modifyKeywordPresetAutoModerationRule|modifyKeywordPresetAutoModerationRule(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake;kotlin.Function1){}[0] + final suspend inline fun modifyMemberProfileAutoModerationRule(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake, kotlin/Function1): dev.kord.common.entity/DiscordAutoModerationRule // dev.kord.rest.service/AutoModerationService.modifyMemberProfileAutoModerationRule|modifyMemberProfileAutoModerationRule(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake;kotlin.Function1){}[0] final suspend inline fun modifyMentionSpamAutoModerationRule(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake, kotlin/Function1): dev.kord.common.entity/DiscordAutoModerationRule // dev.kord.rest.service/AutoModerationService.modifyMentionSpamAutoModerationRule|modifyMentionSpamAutoModerationRule(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake;kotlin.Function1){}[0] final suspend inline fun modifySpamAutoModerationRule(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake, kotlin/Function1): dev.kord.common.entity/DiscordAutoModerationRule // dev.kord.rest.service/AutoModerationService.modifySpamAutoModerationRule|modifySpamAutoModerationRule(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake;kotlin.Function1){}[0] final suspend inline fun modifyUntypedAutoModerationRule(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake, kotlin/Function1): dev.kord.common.entity/DiscordAutoModerationRule // dev.kord.rest.service/AutoModerationService.modifyUntypedAutoModerationRule|modifyUntypedAutoModerationRule(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake;kotlin.Function1){}[0] @@ -7853,6 +7899,11 @@ final fun (dev.kord.rest.builder.automoderation/AllowedKeywordsAutoModerationRul final fun (dev.kord.rest.builder.automoderation/AllowedKeywordsAutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/allowSuffixKeyword(kotlin/String) // dev.kord.rest.builder.automoderation/allowSuffixKeyword|allowSuffixKeyword@dev.kord.rest.builder.automoderation.AllowedKeywordsAutoModerationRuleBuilder(kotlin.String){}[0] final fun (dev.kord.rest.builder.automoderation/AutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/exemptChannel(dev.kord.common.entity/Snowflake) // dev.kord.rest.builder.automoderation/exemptChannel|exemptChannel@dev.kord.rest.builder.automoderation.AutoModerationRuleBuilder(dev.kord.common.entity.Snowflake){}[0] final fun (dev.kord.rest.builder.automoderation/AutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/exemptRole(dev.kord.common.entity/Snowflake) // dev.kord.rest.builder.automoderation/exemptRole|exemptRole@dev.kord.rest.builder.automoderation.AutoModerationRuleBuilder(dev.kord.common.entity.Snowflake){}[0] +final fun (dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/anywhereKeyword(kotlin/String) // dev.kord.rest.builder.automoderation/anywhereKeyword|anywhereKeyword@dev.kord.rest.builder.automoderation.FilteredKeywordsAutoModerationRuleBuilder(kotlin.String){}[0] +final fun (dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/keyword(kotlin/String) // dev.kord.rest.builder.automoderation/keyword|keyword@dev.kord.rest.builder.automoderation.FilteredKeywordsAutoModerationRuleBuilder(kotlin.String){}[0] +final fun (dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/prefixKeyword(kotlin/String) // dev.kord.rest.builder.automoderation/prefixKeyword|prefixKeyword@dev.kord.rest.builder.automoderation.FilteredKeywordsAutoModerationRuleBuilder(kotlin.String){}[0] +final fun (dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/regexPattern(kotlin/String) // dev.kord.rest.builder.automoderation/regexPattern|regexPattern@dev.kord.rest.builder.automoderation.FilteredKeywordsAutoModerationRuleBuilder(kotlin.String){}[0] +final fun (dev.kord.rest.builder.automoderation/FilteredKeywordsAutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/suffixKeyword(kotlin/String) // dev.kord.rest.builder.automoderation/suffixKeyword|suffixKeyword@dev.kord.rest.builder.automoderation.FilteredKeywordsAutoModerationRuleBuilder(kotlin.String){}[0] final fun (dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/anywhereKeyword(kotlin/String) // dev.kord.rest.builder.automoderation/anywhereKeyword|anywhereKeyword@dev.kord.rest.builder.automoderation.KeywordAutoModerationRuleBuilder(kotlin.String){}[0] final fun (dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/keyword(kotlin/String) // dev.kord.rest.builder.automoderation/keyword|keyword@dev.kord.rest.builder.automoderation.KeywordAutoModerationRuleBuilder(kotlin.String){}[0] final fun (dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/prefixKeyword(kotlin/String) // dev.kord.rest.builder.automoderation/prefixKeyword|prefixKeyword@dev.kord.rest.builder.automoderation.KeywordAutoModerationRuleBuilder(kotlin.String){}[0] @@ -7881,6 +7932,8 @@ final fun dev.kord.rest.request/KtorRequestHandler(kotlin/String, dev.kord.rest. final fun dev.kord.rest.service/RestClient(kotlin/String): dev.kord.rest.service/RestClient // dev.kord.rest.service/RestClient|RestClient(kotlin.String){}[0] final inline fun (dev.kord.rest.builder.automoderation/AutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/blockMessage(kotlin/Function1 = ...) // dev.kord.rest.builder.automoderation/blockMessage|blockMessage@dev.kord.rest.builder.automoderation.AutoModerationRuleBuilder(kotlin.Function1){}[0] final inline fun (dev.kord.rest.builder.automoderation/AutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/sendAlertMessage(dev.kord.common.entity/Snowflake, kotlin/Function1 = ...) // dev.kord.rest.builder.automoderation/sendAlertMessage|sendAlertMessage@dev.kord.rest.builder.automoderation.AutoModerationRuleBuilder(dev.kord.common.entity.Snowflake;kotlin.Function1){}[0] +final inline fun (dev.kord.rest.builder.automoderation/BlockMessageAutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/blockMessage(kotlin/Function1 = ...) // dev.kord.rest.builder.automoderation/blockMessage|blockMessage@dev.kord.rest.builder.automoderation.BlockMessageAutoModerationRuleBuilder(kotlin.Function1){}[0] +final inline fun (dev.kord.rest.builder.automoderation/MemberProfileAutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/blockMemberInteraction(kotlin/Function1 = ...) // dev.kord.rest.builder.automoderation/blockMemberInteraction|blockMemberInteraction@dev.kord.rest.builder.automoderation.MemberProfileAutoModerationRuleBuilder(kotlin.Function1){}[0] final inline fun (dev.kord.rest.builder.automoderation/TimeoutAutoModerationRuleBuilder).dev.kord.rest.builder.automoderation/timeout(kotlin.time/Duration, kotlin/Function1 = ...) // dev.kord.rest.builder.automoderation/timeout|timeout@dev.kord.rest.builder.automoderation.TimeoutAutoModerationRuleBuilder(kotlin.time.Duration;kotlin.Function1){}[0] final inline fun (dev.kord.rest.builder.channel/PermissionOverwritesBuilder).dev.kord.rest.builder.channel/addMemberOverwrite(dev.kord.common.entity/Snowflake, kotlin/Function1) // dev.kord.rest.builder.channel/addMemberOverwrite|addMemberOverwrite@dev.kord.rest.builder.channel.PermissionOverwritesBuilder(dev.kord.common.entity.Snowflake;kotlin.Function1){}[0] final inline fun (dev.kord.rest.builder.channel/PermissionOverwritesBuilder).dev.kord.rest.builder.channel/addRoleOverwrite(dev.kord.common.entity/Snowflake, kotlin/Function1) // dev.kord.rest.builder.channel/addRoleOverwrite|addRoleOverwrite@dev.kord.rest.builder.channel.PermissionOverwritesBuilder(dev.kord.common.entity.Snowflake;kotlin.Function1){}[0] diff --git a/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationActionBuilder.kt b/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationActionBuilder.kt index 200c64afc39..b36b43ebd6f 100644 --- a/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationActionBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationActionBuilder.kt @@ -80,3 +80,13 @@ public class TimeoutAutoModerationActionBuilder( override fun buildMetadata(): Optional.Value = DiscordAutoModerationActionMetadata(durationSeconds = duration.optional()).optional() } + +/** An [AutoModerationActionBuilder] for building actions with type [BlockMemberInteraction]. */ +// Keep it as a class in case Discord adds more options in the future. This has happened in the past: +// https://github.com/kordlib/kord/pull/774/files#diff-62348f559af97a22f3c91fb2c93e451395b4bd53c6cecf312f681d8b5356491c +@Suppress("CanSealedSubClassBeObject") +@KordDsl +public class BlockMemberInteractionAutoModerationActionBuilder : AutoModerationActionBuilder() { + + override val type: BlockMemberInteraction get() = BlockMemberInteraction +} diff --git a/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleBuilder.kt b/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleBuilder.kt index b9bd19072b9..f7f72b6904a 100644 --- a/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleBuilder.kt @@ -66,15 +66,6 @@ public sealed interface AutoModerationRuleBuilder : AuditBuilder { public var exemptChannels: MutableList? } -/** Add a [BlockMessage] action which will execute whenever the rule is triggered. */ -public inline fun AutoModerationRuleBuilder.blockMessage( - builder: BlockMessageAutoModerationActionBuilder.() -> Unit = {}, -) { - contract { callsInPlace(builder, EXACTLY_ONCE) } - val action = BlockMessageAutoModerationActionBuilder().apply(builder) - actions?.add(action) ?: assignActions(mutableListOf(action)) -} - /** * Add a [SendAlertMessage] action which will execute whenever the rule is triggered. * @@ -109,6 +100,22 @@ public sealed interface TypedAutoModerationRuleBuilder : AutoModerationRuleBuild } +// -------- interfaces for supported actions shared between rule types -------- + +/** An [AutoModerationRuleBuilder] for building rules that can have a [BlockMessage] action. */ +@KordDsl +public sealed interface BlockMessageAutoModerationRuleBuilder : TypedAutoModerationRuleBuilder + +/** Add a [BlockMessage] action which will execute whenever the rule is triggered. */ +public inline fun BlockMessageAutoModerationRuleBuilder.blockMessage( + builder: BlockMessageAutoModerationActionBuilder.() -> Unit = {}, +) { + contract { callsInPlace(builder, EXACTLY_ONCE) } + val action = BlockMessageAutoModerationActionBuilder().apply(builder) + actions?.add(action) ?: assignActions(mutableListOf(action)) +} + + /** An [AutoModerationRuleBuilder] for building rules that can have a [Timeout] action. */ @KordDsl public sealed interface TimeoutAutoModerationRuleBuilder : TypedAutoModerationRuleBuilder @@ -130,154 +137,168 @@ public inline fun TimeoutAutoModerationRuleBuilder.timeout( } -/** An [AutoModerationRuleBuilder] for building rules that can have [allowedKeywords]. */ +// -------- interfaces for supported options shared between rule types -------- + +/** An [AutoModerationRuleBuilder] for building rules that can have [keywords] and [regexPatterns]. */ @KordDsl -public sealed interface AllowedKeywordsAutoModerationRuleBuilder : TypedAutoModerationRuleBuilder { +public sealed interface FilteredKeywordsAutoModerationRuleBuilder : TypedAutoModerationRuleBuilder { /** - * Substrings which should not trigger the rule. + * Substrings which will be searched for in content (maximum of 1000). * * A keyword can be a phrase which contains multiple words. * [Wildcard symbols](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) * can be used to customize how each keyword will be matched. Each keyword must be 60 characters or less. */ - public var allowedKeywords: MutableList? + public var keywords: MutableList? + + /** + * Regular expression patterns which will be matched against content (maximum of 10). + * + * Only Rust flavored regex is currently supported. Each regex pattern must be 260 characters or less. + */ + public var regexPatterns: MutableList? } /** - * Add a [keyword] to [allowedKeywords][AllowedKeywordsAutoModerationRuleBuilder.allowedKeywords]. + * Add a [keyword] to [keywords][FilteredKeywordsAutoModerationRuleBuilder.keywords] (maximum of 1000). * * A keyword can be a phrase which contains multiple words. * [Wildcard symbols](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) * can be used to customize how each keyword will be matched. Each keyword must be 60 characters or less. */ -public fun AllowedKeywordsAutoModerationRuleBuilder.allowKeyword(keyword: String) { - allowedKeywords?.add(keyword) ?: run { allowedKeywords = mutableListOf(keyword) } +public fun FilteredKeywordsAutoModerationRuleBuilder.keyword(keyword: String) { + keywords?.add(keyword) ?: run { keywords = mutableListOf(keyword) } } /** * Add a [keyword] with keyword matching strategy * [Prefix](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) - * to [allowedKeywords][AllowedKeywordsAutoModerationRuleBuilder.allowedKeywords]. + * to [keywords][FilteredKeywordsAutoModerationRuleBuilder.keywords] (maximum of 1000). * * A keyword can be a phrase which contains multiple words. Each keyword must be 60 characters or less. */ -public fun AllowedKeywordsAutoModerationRuleBuilder.allowPrefixKeyword(keyword: String) { - allowKeyword("$keyword*") +public fun FilteredKeywordsAutoModerationRuleBuilder.prefixKeyword(keyword: String) { + keyword("$keyword*") } /** * Add a [keyword] with keyword matching strategy * [Suffix](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) - * to [allowedKeywords][AllowedKeywordsAutoModerationRuleBuilder.allowedKeywords]. + * to [keywords][FilteredKeywordsAutoModerationRuleBuilder.keywords] (maximum of 1000). * * A keyword can be a phrase which contains multiple words. Each keyword must be 60 characters or less. */ -public fun AllowedKeywordsAutoModerationRuleBuilder.allowSuffixKeyword(keyword: String) { - allowKeyword("*$keyword") +public fun FilteredKeywordsAutoModerationRuleBuilder.suffixKeyword(keyword: String) { + keyword("*$keyword") } /** * Add a [keyword] with keyword matching strategy * [Anywhere](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) - * to [allowedKeywords][AllowedKeywordsAutoModerationRuleBuilder.allowedKeywords]. + * to [keywords][FilteredKeywordsAutoModerationRuleBuilder.keywords] (maximum of 1000). * * A keyword can be a phrase which contains multiple words. Each keyword must be 60 characters or less. */ -public fun AllowedKeywordsAutoModerationRuleBuilder.allowAnywhereKeyword(keyword: String) { - allowKeyword("*$keyword*") +public fun FilteredKeywordsAutoModerationRuleBuilder.anywhereKeyword(keyword: String) { + keyword("*$keyword*") } +/** + * Add a [pattern] to [regexPatterns][FilteredKeywordsAutoModerationRuleBuilder.regexPatterns] (maximum of 10). + * + * Only Rust flavored regex is currently supported. Each regex pattern must be 260 characters or less. + */ +public fun FilteredKeywordsAutoModerationRuleBuilder.regexPattern(pattern: String) { + regexPatterns?.add(pattern) ?: run { regexPatterns = mutableListOf(pattern) } +} -/** An [AutoModerationRuleBuilder] for building rules with trigger type [Keyword]. */ -@KordDsl -public sealed interface KeywordAutoModerationRuleBuilder : - TimeoutAutoModerationRuleBuilder, - AllowedKeywordsAutoModerationRuleBuilder { - override val triggerType: Keyword get() = Keyword +/** An [AutoModerationRuleBuilder] for building rules that can have [allowedKeywords]. */ +@KordDsl +public sealed interface AllowedKeywordsAutoModerationRuleBuilder : TypedAutoModerationRuleBuilder { /** - * Substrings which will be searched for in content (maximum of 1000). + * Substrings which should not trigger the rule. * * A keyword can be a phrase which contains multiple words. * [Wildcard symbols](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) * can be used to customize how each keyword will be matched. Each keyword must be 60 characters or less. */ - public var keywords: MutableList? - - /** - * Regular expression patterns which will be matched against content (maximum of 10). - * - * Only Rust flavored regex is currently supported. Each regex pattern must be 260 characters or less. - */ - public var regexPatterns: MutableList? + public var allowedKeywords: MutableList? } /** - * Add a [keyword] to [keywords][KeywordAutoModerationRuleBuilder.keywords] (maximum of 1000). + * Add a [keyword] to [allowedKeywords][AllowedKeywordsAutoModerationRuleBuilder.allowedKeywords]. * * A keyword can be a phrase which contains multiple words. * [Wildcard symbols](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) * can be used to customize how each keyword will be matched. Each keyword must be 60 characters or less. */ -public fun KeywordAutoModerationRuleBuilder.keyword(keyword: String) { - keywords?.add(keyword) ?: run { keywords = mutableListOf(keyword) } +public fun AllowedKeywordsAutoModerationRuleBuilder.allowKeyword(keyword: String) { + allowedKeywords?.add(keyword) ?: run { allowedKeywords = mutableListOf(keyword) } } /** * Add a [keyword] with keyword matching strategy * [Prefix](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) - * to [keywords][KeywordAutoModerationRuleBuilder.keywords] (maximum of 1000). + * to [allowedKeywords][AllowedKeywordsAutoModerationRuleBuilder.allowedKeywords]. * * A keyword can be a phrase which contains multiple words. Each keyword must be 60 characters or less. */ -public fun KeywordAutoModerationRuleBuilder.prefixKeyword(keyword: String) { - keyword("$keyword*") +public fun AllowedKeywordsAutoModerationRuleBuilder.allowPrefixKeyword(keyword: String) { + allowKeyword("$keyword*") } /** * Add a [keyword] with keyword matching strategy * [Suffix](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) - * to [keywords][KeywordAutoModerationRuleBuilder.keywords] (maximum of 1000). + * to [allowedKeywords][AllowedKeywordsAutoModerationRuleBuilder.allowedKeywords]. * * A keyword can be a phrase which contains multiple words. Each keyword must be 60 characters or less. */ -public fun KeywordAutoModerationRuleBuilder.suffixKeyword(keyword: String) { - keyword("*$keyword") +public fun AllowedKeywordsAutoModerationRuleBuilder.allowSuffixKeyword(keyword: String) { + allowKeyword("*$keyword") } /** * Add a [keyword] with keyword matching strategy * [Anywhere](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) - * to [keywords][KeywordAutoModerationRuleBuilder.keywords] (maximum of 1000). + * to [allowedKeywords][AllowedKeywordsAutoModerationRuleBuilder.allowedKeywords]. * * A keyword can be a phrase which contains multiple words. Each keyword must be 60 characters or less. */ -public fun KeywordAutoModerationRuleBuilder.anywhereKeyword(keyword: String) { - keyword("*$keyword*") +public fun AllowedKeywordsAutoModerationRuleBuilder.allowAnywhereKeyword(keyword: String) { + allowKeyword("*$keyword*") } -/** - * Add a [pattern] to [regexPatterns][KeywordAutoModerationRuleBuilder.regexPatterns] (maximum of 10). - * - * Only Rust flavored regex is currently supported. Each regex pattern must be 260 characters or less. - */ -public fun KeywordAutoModerationRuleBuilder.regexPattern(pattern: String) { - regexPatterns?.add(pattern) ?: run { regexPatterns = mutableListOf(pattern) } + +// -------- builders for concrete rule types -------- + +/** An [AutoModerationRuleBuilder] for building rules with trigger type [Keyword]. */ +@KordDsl +public sealed interface KeywordAutoModerationRuleBuilder : + BlockMessageAutoModerationRuleBuilder, + TimeoutAutoModerationRuleBuilder, + FilteredKeywordsAutoModerationRuleBuilder, + AllowedKeywordsAutoModerationRuleBuilder { + + override val triggerType: Keyword get() = Keyword } /** An [AutoModerationRuleBuilder] for building rules with trigger type [Spam]. */ @KordDsl -public sealed interface SpamAutoModerationRuleBuilder : TypedAutoModerationRuleBuilder { +public sealed interface SpamAutoModerationRuleBuilder : BlockMessageAutoModerationRuleBuilder { override val triggerType: Spam get() = Spam } /** An [AutoModerationRuleBuilder] for building rules with trigger type [KeywordPreset]. */ @KordDsl -public sealed interface KeywordPresetAutoModerationRuleBuilder : AllowedKeywordsAutoModerationRuleBuilder { +public sealed interface KeywordPresetAutoModerationRuleBuilder : + BlockMessageAutoModerationRuleBuilder, + AllowedKeywordsAutoModerationRuleBuilder { override val triggerType: KeywordPreset get() = KeywordPreset @@ -299,7 +320,9 @@ public fun KeywordPresetAutoModerationRuleBuilder.preset(preset: AutoModerationR /** An [AutoModerationRuleBuilder] for building rules with trigger type [MentionSpam]. */ @KordDsl -public sealed interface MentionSpamAutoModerationRuleBuilder : TimeoutAutoModerationRuleBuilder { +public sealed interface MentionSpamAutoModerationRuleBuilder : + BlockMessageAutoModerationRuleBuilder, + TimeoutAutoModerationRuleBuilder { override val triggerType: MentionSpam get() = MentionSpam @@ -309,3 +332,70 @@ public sealed interface MentionSpamAutoModerationRuleBuilder : TimeoutAutoModera /** Whether to automatically detect mention raids. */ public var mentionRaidProtectionEnabled: Boolean? } + + +/** An [AutoModerationRuleBuilder] for building rules with trigger type [MemberProfile]. */ +public sealed interface MemberProfileAutoModerationRuleBuilder : + FilteredKeywordsAutoModerationRuleBuilder, + AllowedKeywordsAutoModerationRuleBuilder { + + override val triggerType: MemberProfile get() = MemberProfile +} + +/** Add a [BlockMemberInteraction] action which will execute whenever the rule is triggered. */ +public inline fun MemberProfileAutoModerationRuleBuilder.blockMemberInteraction( + builder: BlockMemberInteractionAutoModerationActionBuilder.() -> Unit = {}, +) { + contract { callsInPlace(builder, EXACTLY_ONCE) } + val action = BlockMemberInteractionAutoModerationActionBuilder().apply(builder) + actions?.add(action) ?: assignActions(mutableListOf(action)) +} + + +// -------- deprecated stuff -------- + +/** Add a [BlockMessage] action which will execute whenever the rule is triggered. */ +@Deprecated( + "Not all Auto Moderation Rules can have a 'BlockMessage' action (e.g. 'MemberProfile' rules can't), so this " + + "extension function is deprecated for 'AutoModerationRuleBuilder'. Use the extension function on " + + "'BlockMessageAutoModerationRuleBuilder' 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 as? BlockMessageAutoModerationRuleBuilder)?.blockMessage { builder() } ?: Unit", + imports = [ + "dev.kord.rest.builder.automoderation.BlockMessageAutoModerationRuleBuilder", + "dev.kord.rest.builder.automoderation.blockMessage", "kotlin.Unit", + ], + ), + DeprecationLevel.WARNING, +) +public inline fun AutoModerationRuleBuilder.blockMessage( + builder: BlockMessageAutoModerationActionBuilder.() -> Unit = {}, +) { + contract { callsInPlace(builder, EXACTLY_ONCE) } + val action = BlockMessageAutoModerationActionBuilder().apply(builder) + actions?.add(action) ?: assignActions(mutableListOf(action)) +} + +private const val MESSAGE = "This extension is now defined on 'FilteredKeywordsAutoModerationRuleBuilder'. The " + + "declaration is kept for binary compatibility, it will be removed in 0.18.0." + +@Deprecated(MESSAGE, level = DeprecationLevel.HIDDEN) +public fun KeywordAutoModerationRuleBuilder.keyword(keyword: String): Unit = + (this as FilteredKeywordsAutoModerationRuleBuilder).keyword(keyword) + +@Deprecated(MESSAGE, level = DeprecationLevel.HIDDEN) +public fun KeywordAutoModerationRuleBuilder.prefixKeyword(keyword: String): Unit = + (this as FilteredKeywordsAutoModerationRuleBuilder).prefixKeyword(keyword) + +@Deprecated(MESSAGE, level = DeprecationLevel.HIDDEN) +public fun KeywordAutoModerationRuleBuilder.suffixKeyword(keyword: String): Unit = + (this as FilteredKeywordsAutoModerationRuleBuilder).suffixKeyword(keyword) + +@Deprecated(MESSAGE, level = DeprecationLevel.HIDDEN) +public fun KeywordAutoModerationRuleBuilder.anywhereKeyword(keyword: String): Unit = + (this as FilteredKeywordsAutoModerationRuleBuilder).anywhereKeyword(keyword) + +@Deprecated(MESSAGE, level = DeprecationLevel.HIDDEN) +public fun KeywordAutoModerationRuleBuilder.regexPattern(pattern: String): Unit = + (this as FilteredKeywordsAutoModerationRuleBuilder).regexPattern(pattern) diff --git a/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleCreateBuilder.kt index 82acfabeb75..9a6b9f3d441 100644 --- a/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleCreateBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleCreateBuilder.kt @@ -135,3 +135,28 @@ public class MentionSpamAutoModerationRuleCreateBuilder( mentionRaidProtectionEnabled = _mentionRaidProtectionEnabled, ).optional() } + +/** A [MemberProfileAutoModerationRuleBuilder] for building [AutoModerationRuleCreateRequest]s. */ +@KordDsl +public class MemberProfileAutoModerationRuleCreateBuilder( + name: String, + eventType: AutoModerationRuleEventType, +) : AutoModerationRuleCreateBuilder(name, eventType), MemberProfileAutoModerationRuleBuilder { + + private var _keywords: Optional> = Optional.Missing() + override var keywords: MutableList? by ::_keywords.delegate() + + private var _regexPatterns: Optional> = Optional.Missing() + override var regexPatterns: MutableList? by ::_regexPatterns.delegate() + + private var _allowedKeywords: Optional> = Optional.Missing() + override var allowedKeywords: MutableList? by ::_allowedKeywords.delegate() + + // triggerMetadata is required for MemberProfile rules + override fun buildTriggerMetadata(): Optional = + DiscordAutoModerationRuleTriggerMetadata( + keywordFilter = _keywords.mapCopy(), + regexPatterns = _regexPatterns.mapCopy(), + allowList = _allowedKeywords.mapCopy(), + ).optional() +} diff --git a/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleModifyBuilder.kt index 0bbeb537c30..69e0ffeb071 100644 --- a/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleModifyBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleModifyBuilder.kt @@ -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(), @@ -164,6 +164,35 @@ public class MentionSpamAutoModerationRuleModifyBuilder : } } +/** A [MemberProfileAutoModerationRuleBuilder] for building [AutoModerationRuleModifyRequest]s. */ +@KordDsl +public class MemberProfileAutoModerationRuleModifyBuilder : + AutoModerationRuleModifyBuilder(), + MemberProfileAutoModerationRuleBuilder { + + private var _keywords: Optional> = Optional.Missing() + override var keywords: MutableList? by ::_keywords.delegate() + + private var _regexPatterns: Optional> = Optional.Missing() + override var regexPatterns: MutableList? by ::_regexPatterns.delegate() + + private var _allowedKeywords: Optional> = Optional.Missing() + override var allowedKeywords: MutableList? by ::_allowedKeywords.delegate() + + override fun buildTriggerMetadata(): Optional { + val keywords = _keywords + val regexPatterns = _regexPatterns + val allowedKeywords = _allowedKeywords + return ifAnyPresent(keywords, regexPatterns, allowedKeywords) { + DiscordAutoModerationRuleTriggerMetadata( + keywordFilter = keywords.mapCopy(), + regexPatterns = regexPatterns.mapCopy(), + allowList = allowedKeywords.mapCopy(), + ) + } + } +} + private inline fun ifAnyPresent(vararg optionals: Optional<*>, block: () -> T): Optional { contract { callsInPlace(block, AT_MOST_ONCE) } diff --git a/rest/src/commonMain/kotlin/service/AutoModerationService.kt b/rest/src/commonMain/kotlin/service/AutoModerationService.kt index a86b592ac22..46c0466c9c6 100644 --- a/rest/src/commonMain/kotlin/service/AutoModerationService.kt +++ b/rest/src/commonMain/kotlin/service/AutoModerationService.kt @@ -79,6 +79,17 @@ public class AutoModerationService(requestHandler: RequestHandler) : RestService return createAutoModerationRule(guildId, request.toRequest(), request.reason) } + public suspend inline fun createMemberProfileAutoModerationRule( + guildId: Snowflake, + name: String, + eventType: AutoModerationRuleEventType, + builder: MemberProfileAutoModerationRuleCreateBuilder.() -> Unit, + ): DiscordAutoModerationRule { + contract { callsInPlace(builder, EXACTLY_ONCE) } + val request = MemberProfileAutoModerationRuleCreateBuilder(name, eventType).apply(builder) + return createAutoModerationRule(guildId, request.toRequest(), request.reason) + } + public suspend fun modifyAutoModerationRule( guildId: Snowflake, ruleId: Snowflake, @@ -141,6 +152,16 @@ public class AutoModerationService(requestHandler: RequestHandler) : RestService return modifyAutoModerationRule(guildId, ruleId, request.toRequest(), request.reason) } + public suspend inline fun modifyMemberProfileAutoModerationRule( + guildId: Snowflake, + ruleId: Snowflake, + builder: MemberProfileAutoModerationRuleModifyBuilder.() -> Unit, + ): DiscordAutoModerationRule { + contract { callsInPlace(builder, EXACTLY_ONCE) } + val request = MemberProfileAutoModerationRuleModifyBuilder().apply(builder) + return modifyAutoModerationRule(guildId, ruleId, request.toRequest(), request.reason) + } + public suspend fun deleteAutoModerationRule( guildId: Snowflake, ruleId: Snowflake,