diff --git a/common/api/common.api b/common/api/common.api index a1f90899457b..1fc28b11f8b2 100644 --- a/common/api/common.api +++ b/common/api/common.api @@ -1711,6 +1711,10 @@ public final class dev/kord/common/entity/ChannelFlag$Companion { public fun values ()[Ldev/kord/common/entity/ChannelFlag; } +public final class dev/kord/common/entity/ChannelFlag$HideMediaDownloadOptions : dev/kord/common/entity/ChannelFlag { + public static final field INSTANCE Ldev/kord/common/entity/ChannelFlag$HideMediaDownloadOptions; +} + public final class dev/kord/common/entity/ChannelFlag$Pinned : dev/kord/common/entity/ChannelFlag { public static final field INSTANCE Ldev/kord/common/entity/ChannelFlag$Pinned; } @@ -1801,6 +1805,10 @@ public final class dev/kord/common/entity/ChannelType$GuildForum : dev/kord/comm public static final field INSTANCE Ldev/kord/common/entity/ChannelType$GuildForum; } +public final class dev/kord/common/entity/ChannelType$GuildMedia : dev/kord/common/entity/ChannelType { + public static final field INSTANCE Ldev/kord/common/entity/ChannelType$GuildMedia; +} + public final class dev/kord/common/entity/ChannelType$GuildNews : dev/kord/common/entity/ChannelType { public static final field INSTANCE Ldev/kord/common/entity/ChannelType$GuildNews; } diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelFlag.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelFlag.kt index 881ed4c69d96..7c74296b3b49 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelFlag.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelFlag.kt @@ -80,6 +80,7 @@ public sealed class ChannelFlag( public fun ordinal(): Int = when (this) { Pinned -> 0 RequireTag -> 1 + HideMediaDownloadOptions -> 2 is Unknown -> Int.MAX_VALUE } @@ -103,16 +104,23 @@ public sealed class ChannelFlag( ) : ChannelFlag(shift) /** - * This thread is pinned to the top of its parent [GuildForum][ChannelType.GuildForum] channel. + * This thread is pinned to the top of its parent [GuildForum][ChannelType.GuildForum] or + * [GuildMedia][ChannelType.GuildMedia] channel. */ public object Pinned : ChannelFlag(1) /** * Whether a tag is required to be specified when creating a thread in a - * [GuildForum][ChannelType.GuildForum] channel. + * [GuildForum][ChannelType.GuildForum] or [GuildMedia][ChannelType.GuildMedia] channel. */ public object RequireTag : ChannelFlag(4) + /** + * When set hides the embedded media download options. Available only for + * [GuildMedia][ChannelType.GuildMedia] channels. + */ + public object HideMediaDownloadOptions : ChannelFlag(15) + public companion object { /** * A [List] of all known [ChannelFlag]s. @@ -121,6 +129,7 @@ public sealed class ChannelFlag( listOf( Pinned, RequireTag, + HideMediaDownloadOptions, ) } @@ -148,6 +157,7 @@ public sealed class ChannelFlag( public fun fromShift(shift: Int): ChannelFlag = when (shift) { 1 -> Pinned 4 -> RequireTag + 15 -> HideMediaDownloadOptions else -> Unknown(shift) } @@ -161,6 +171,7 @@ public sealed class ChannelFlag( public open fun valueOf(name: String): ChannelFlag = when (name) { "Pinned" -> Pinned "RequireTag" -> RequireTag + "HideMediaDownloadOptions" -> HideMediaDownloadOptions else -> throw IllegalArgumentException(name) } diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelType.kt index 9bf562fc9433..34efb7755ec7 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelType.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelType.kt @@ -117,6 +117,11 @@ public sealed class ChannelType( */ public object GuildForum : ChannelType(15) + /** + * A channel that can only contain threads, similar to [GuildForum] channels. + */ + public object GuildMedia : ChannelType(16) + internal object Serializer : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("dev.kord.common.entity.ChannelType", PrimitiveKind.INT) @@ -146,6 +151,7 @@ public sealed class ChannelType( GuildStageVoice, GuildDirectory, GuildForum, + GuildMedia, ) } @@ -167,6 +173,7 @@ public sealed class ChannelType( 13 -> GuildStageVoice 14 -> GuildDirectory 15 -> GuildForum + 16 -> GuildMedia else -> Unknown(value, null) } } diff --git a/common/src/commonMain/kotlin/entity/DiscordChannel.kt b/common/src/commonMain/kotlin/entity/DiscordChannel.kt index d85d93a4686e..63289d862da7 100644 --- a/common/src/commonMain/kotlin/entity/DiscordChannel.kt +++ b/common/src/commonMain/kotlin/entity/DiscordChannel.kt @@ -37,6 +37,10 @@ "Student-Hubs-FAQ) containing the listed servers.", ), Entry("GuildForum", intValue = 15, kDoc = "A channel that can only contain threads."), + Entry( + "GuildMedia", intValue = 16, + kDoc = "A channel that can only contain threads, similar to [GuildForum] channels.", + ), ], ) @@ -47,12 +51,18 @@ entries = [ Entry( "Pinned", shift = 1, - kDoc = "This thread is pinned to the top of its parent [GuildForum][ChannelType.GuildForum] channel.", + kDoc = "This thread is pinned to the top of its parent [GuildForum][ChannelType.GuildForum] or " + + "[GuildMedia][ChannelType.GuildMedia] channel.", ), Entry( "RequireTag", shift = 4, kDoc = "Whether a tag is required to be specified when creating a thread in a " + - "[GuildForum][ChannelType.GuildForum] channel.", + "[GuildForum][ChannelType.GuildForum] or [GuildMedia][ChannelType.GuildMedia] channel.", + ), + Entry( + "HideMediaDownloadOptions", shift = 15, noStaticFieldIfEntityWasEnum = true, + kDoc = "When set hides the embedded media download options. Available only for " + + "[GuildMedia][ChannelType.GuildMedia] channels.", ), ], ) diff --git a/core/api/core.api b/core/api/core.api index 5d184781e3d4..8fb514658e4d 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -397,6 +397,8 @@ public final class dev/kord/core/behavior/GuildBehaviorKt { public static synthetic fun createKeywordAutoModerationRule$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 createKeywordPresetAutoModerationRule (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 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 createMentionSpamAutoModerationRule (Ldev/kord/core/behavior/GuildBehavior;Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;ILkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)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;ILkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; @@ -1098,14 +1100,11 @@ public final class dev/kord/core/behavior/channel/ChannelBehaviorKt { public static synthetic fun ChannelBehavior$default (Ldev/kord/common/entity/Snowflake;Ldev/kord/core/Kord;Ldev/kord/core/supplier/EntitySupplyStrategy;ILjava/lang/Object;)Ldev/kord/core/behavior/channel/ChannelBehavior; } -public abstract interface class dev/kord/core/behavior/channel/ForumChannelBehavior : dev/kord/core/behavior/channel/threads/ThreadParentChannelBehavior { +public abstract interface class dev/kord/core/behavior/channel/ForumChannelBehavior : dev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior { public abstract fun asChannel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun asChannelOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun fetchChannel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun fetchChannelOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public abstract fun getActiveThreads ()Lkotlinx/coroutines/flow/Flow; - public abstract fun getPublicArchivedThreads (Lkotlinx/datetime/Instant;Ljava/lang/Integer;)Lkotlinx/coroutines/flow/Flow; - public abstract fun startPublicThread (Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/ForumChannelBehavior; } @@ -1202,6 +1201,38 @@ public final class dev/kord/core/behavior/channel/GuildMessageChannelBehavior$De public static fun withStrategy (Ldev/kord/core/behavior/channel/GuildMessageChannelBehavior;Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/GuildMessageChannelBehavior; } +public abstract interface class dev/kord/core/behavior/channel/MediaChannelBehavior : dev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior { + public abstract fun asChannel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun asChannelOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun fetchChannel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun fetchChannelOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/MediaChannelBehavior; +} + +public final class dev/kord/core/behavior/channel/MediaChannelBehavior$DefaultImpls { + public static fun addOverwrite (Ldev/kord/core/behavior/channel/MediaChannelBehavior;Ldev/kord/core/entity/PermissionOverwrite;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun asChannel (Ldev/kord/core/behavior/channel/MediaChannelBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun asChannelOrNull (Ldev/kord/core/behavior/channel/MediaChannelBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun compareTo (Ldev/kord/core/behavior/channel/MediaChannelBehavior;Ldev/kord/core/entity/Entity;)I + public static fun delete (Ldev/kord/core/behavior/channel/MediaChannelBehavior;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun fetchChannel (Ldev/kord/core/behavior/channel/MediaChannelBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun fetchChannelOrNull (Ldev/kord/core/behavior/channel/MediaChannelBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getActiveThreads (Ldev/kord/core/behavior/channel/MediaChannelBehavior;)Lkotlinx/coroutines/flow/Flow; + public static fun getGuild (Ldev/kord/core/behavior/channel/MediaChannelBehavior;)Ldev/kord/core/behavior/GuildBehavior; + public static fun getGuild (Ldev/kord/core/behavior/channel/MediaChannelBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getGuildOrNull (Ldev/kord/core/behavior/channel/MediaChannelBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getInvites (Ldev/kord/core/behavior/channel/MediaChannelBehavior;)Lkotlinx/coroutines/flow/Flow; + public static fun getMention (Ldev/kord/core/behavior/channel/MediaChannelBehavior;)Ljava/lang/String; + public static fun getPosition (Ldev/kord/core/behavior/channel/MediaChannelBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getPublicArchivedThreads (Ldev/kord/core/behavior/channel/MediaChannelBehavior;Lkotlinx/datetime/Instant;Ljava/lang/Integer;)Lkotlinx/coroutines/flow/Flow; + public static fun getWebhooks (Ldev/kord/core/behavior/channel/MediaChannelBehavior;)Lkotlinx/coroutines/flow/Flow; + public static fun startPublicThread (Ldev/kord/core/behavior/channel/MediaChannelBehavior;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/kord/core/behavior/channel/MediaChannelBehaviorKt { + public static final fun edit (Ldev/kord/core/behavior/channel/MediaChannelBehavior;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + public abstract interface class dev/kord/core/behavior/channel/MessageChannelBehavior : dev/kord/core/behavior/channel/ChannelBehavior, dev/kord/core/entity/Strategizable { public abstract fun asChannel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun asChannelOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -1631,6 +1662,37 @@ public final class dev/kord/core/behavior/channel/threads/ThreadChannelBehaviorK public static final fun edit (Ldev/kord/core/behavior/channel/threads/ThreadChannelBehavior;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } +public abstract interface class dev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior : dev/kord/core/behavior/channel/threads/ThreadParentChannelBehavior { + public abstract fun asChannel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun asChannelOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun fetchChannel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun fetchChannelOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun getActiveThreads ()Lkotlinx/coroutines/flow/Flow; + public abstract fun getPublicArchivedThreads (Lkotlinx/datetime/Instant;Ljava/lang/Integer;)Lkotlinx/coroutines/flow/Flow; + public abstract fun startPublicThread (Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior; +} + +public final class dev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior$DefaultImpls { + public static fun addOverwrite (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;Ldev/kord/core/entity/PermissionOverwrite;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun asChannel (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun asChannelOrNull (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun compareTo (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;Ldev/kord/core/entity/Entity;)I + public static fun delete (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun fetchChannel (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun fetchChannelOrNull (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getActiveThreads (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;)Lkotlinx/coroutines/flow/Flow; + public static fun getGuild (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;)Ldev/kord/core/behavior/GuildBehavior; + public static fun getGuild (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getGuildOrNull (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getInvites (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;)Lkotlinx/coroutines/flow/Flow; + public static fun getMention (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;)Ljava/lang/String; + public static fun getPosition (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getPublicArchivedThreads (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;Lkotlinx/datetime/Instant;Ljava/lang/Integer;)Lkotlinx/coroutines/flow/Flow; + public static fun getWebhooks (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;)Lkotlinx/coroutines/flow/Flow; + public static fun startPublicThread (Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + public abstract interface class dev/kord/core/behavior/channel/threads/ThreadParentChannelBehavior : dev/kord/core/behavior/channel/CategorizableChannelBehavior { public abstract fun asChannel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun asChannelOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -8007,7 +8069,7 @@ public final class dev/kord/core/entity/channel/DmChannel : dev/kord/core/entity public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/channel/MessageChannel; } -public final class dev/kord/core/entity/channel/ForumChannel : dev/kord/core/behavior/channel/ForumChannelBehavior, dev/kord/core/entity/channel/ThreadParentChannel { +public final class dev/kord/core/entity/channel/ForumChannel : dev/kord/core/behavior/channel/ForumChannelBehavior, dev/kord/core/entity/channel/thread/ThreadOnlyChannel { public fun (Ldev/kord/core/cache/data/ChannelData;Ldev/kord/core/Kord;Ldev/kord/core/supplier/EntitySupplier;)V public synthetic fun (Ldev/kord/core/cache/data/ChannelData;Ldev/kord/core/Kord;Ldev/kord/core/supplier/EntitySupplier;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun addOverwrite (Ldev/kord/core/entity/PermissionOverwrite;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -8016,18 +8078,19 @@ public final class dev/kord/core/entity/channel/ForumChannel : dev/kord/core/beh public fun compareTo (Ldev/kord/core/entity/Entity;)I public synthetic fun compareTo (Ljava/lang/Object;)I public fun delete (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun equals (Ljava/lang/Object;)Z public fun fetchChannel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun fetchChannelOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getActiveThreads ()Lkotlinx/coroutines/flow/Flow; - public final fun getAvailableTags ()Ljava/util/List; + public fun getAvailableTags ()Ljava/util/List; public fun getCategory ()Ldev/kord/core/behavior/channel/CategoryBehavior; public fun getCategoryId ()Ldev/kord/common/entity/Snowflake; public fun getData ()Ldev/kord/core/cache/data/ChannelData; - public final fun getDefaultAutoArchiveDuration ()Ldev/kord/common/entity/ArchiveDuration; + public fun getDefaultAutoArchiveDuration ()Ldev/kord/common/entity/ArchiveDuration; public final fun getDefaultForumLayout ()Ldev/kord/common/entity/ForumLayoutType; - public final fun getDefaultReactionEmoji ()Ldev/kord/common/entity/DefaultReaction; - public final fun getDefaultSortOrder ()Ldev/kord/common/entity/SortOrderType; - public final fun getDefaultThreadRateLimitPerUser-FghU774 ()Lkotlin/time/Duration; + public fun getDefaultReactionEmoji ()Ldev/kord/common/entity/DefaultReaction; + public fun getDefaultSortOrder ()Ldev/kord/common/entity/SortOrderType; + public fun getDefaultThreadRateLimitPerUser-FghU774 ()Lkotlin/time/Duration; public fun getEffectivePermissions (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getFlags ()Ldev/kord/common/entity/ChannelFlags; public fun getGuild ()Ldev/kord/core/behavior/GuildBehavior; @@ -8037,6 +8100,7 @@ public final class dev/kord/core/entity/channel/ForumChannel : dev/kord/core/beh public fun getId ()Ldev/kord/common/entity/Snowflake; public fun getInvites ()Lkotlinx/coroutines/flow/Flow; public fun getKord ()Ldev/kord/core/Kord; + public fun getLastThreadId ()Ldev/kord/common/entity/Snowflake; public fun getMention ()Ljava/lang/String; public fun getName ()Ljava/lang/String; public fun getPermissionOverwrites ()Ljava/util/Set; @@ -8044,13 +8108,14 @@ public final class dev/kord/core/entity/channel/ForumChannel : dev/kord/core/beh public fun getPermissionOverwritesForRole (Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/entity/PermissionOverwriteEntity; public fun getPosition (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getPublicArchivedThreads (Lkotlinx/datetime/Instant;Ljava/lang/Integer;)Lkotlinx/coroutines/flow/Flow; - public final fun getRateLimitPerUser-FghU774 ()Lkotlin/time/Duration; + public fun getRateLimitPerUser-FghU774 ()Lkotlin/time/Duration; public fun getRawPosition ()I public fun getSupplier ()Ldev/kord/core/supplier/EntitySupplier; - public final fun getTopic ()Ljava/lang/String; + public fun getTopic ()Ljava/lang/String; public fun getType ()Ldev/kord/common/entity/ChannelType; public fun getWebhooks ()Lkotlinx/coroutines/flow/Flow; - public final fun isNsfw ()Z + public fun hashCode ()I + public fun isNsfw ()Z public fun startPublicThread (Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun toString ()Ljava/lang/String; public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/CategorizableChannelBehavior; @@ -8058,6 +8123,7 @@ public final class dev/kord/core/entity/channel/ForumChannel : dev/kord/core/beh public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/ForumChannelBehavior; public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/GuildChannelBehavior; public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/TopGuildChannelBehavior; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior; public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/threads/ThreadParentChannelBehavior; 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/channel/CategorizableChannel; @@ -8066,6 +8132,7 @@ public final class dev/kord/core/entity/channel/ForumChannel : dev/kord/core/beh public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/channel/GuildChannel; public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/channel/ThreadParentChannel; public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/channel/TopGuildChannel; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel; } public abstract interface class dev/kord/core/entity/channel/GuildChannel : dev/kord/core/behavior/channel/GuildChannelBehavior, dev/kord/core/entity/channel/Channel { @@ -8131,6 +8198,71 @@ public final class dev/kord/core/entity/channel/GuildMessageChannel$DefaultImpls public static fun typeUntil (Ldev/kord/core/entity/channel/GuildMessageChannel;Lkotlinx/datetime/Instant;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } +public final class dev/kord/core/entity/channel/MediaChannel : dev/kord/core/behavior/channel/MediaChannelBehavior, dev/kord/core/entity/channel/thread/ThreadOnlyChannel { + public fun (Ldev/kord/core/cache/data/ChannelData;Ldev/kord/core/Kord;Ldev/kord/core/supplier/EntitySupplier;)V + public synthetic fun (Ldev/kord/core/cache/data/ChannelData;Ldev/kord/core/Kord;Ldev/kord/core/supplier/EntitySupplier;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun addOverwrite (Ldev/kord/core/entity/PermissionOverwrite;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun asChannel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun asChannelOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun compareTo (Ldev/kord/core/entity/Entity;)I + public synthetic fun compareTo (Ljava/lang/Object;)I + public fun delete (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun equals (Ljava/lang/Object;)Z + public fun fetchChannel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun fetchChannelOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun getActiveThreads ()Lkotlinx/coroutines/flow/Flow; + public fun getAvailableTags ()Ljava/util/List; + public fun getCategory ()Ldev/kord/core/behavior/channel/CategoryBehavior; + public fun getCategoryId ()Ldev/kord/common/entity/Snowflake; + public fun getData ()Ldev/kord/core/cache/data/ChannelData; + public fun getDefaultAutoArchiveDuration ()Ldev/kord/common/entity/ArchiveDuration; + public fun getDefaultReactionEmoji ()Ldev/kord/common/entity/DefaultReaction; + public fun getDefaultSortOrder ()Ldev/kord/common/entity/SortOrderType; + public fun getDefaultThreadRateLimitPerUser-FghU774 ()Lkotlin/time/Duration; + public fun getEffectivePermissions (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun getFlags ()Ldev/kord/common/entity/ChannelFlags; + public fun getGuild ()Ldev/kord/core/behavior/GuildBehavior; + public fun getGuild (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun getGuildId ()Ldev/kord/common/entity/Snowflake; + public fun getGuildOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun getId ()Ldev/kord/common/entity/Snowflake; + public fun getInvites ()Lkotlinx/coroutines/flow/Flow; + public fun getKord ()Ldev/kord/core/Kord; + public fun getLastThreadId ()Ldev/kord/common/entity/Snowflake; + public fun getMention ()Ljava/lang/String; + public fun getName ()Ljava/lang/String; + public fun getPermissionOverwrites ()Ljava/util/Set; + public fun getPermissionOverwritesForMember (Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/entity/PermissionOverwriteEntity; + public fun getPermissionOverwritesForRole (Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/entity/PermissionOverwriteEntity; + public fun getPosition (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun getPublicArchivedThreads (Lkotlinx/datetime/Instant;Ljava/lang/Integer;)Lkotlinx/coroutines/flow/Flow; + public fun getRateLimitPerUser-FghU774 ()Lkotlin/time/Duration; + public fun getRawPosition ()I + public fun getSupplier ()Ldev/kord/core/supplier/EntitySupplier; + public fun getTopic ()Ljava/lang/String; + public fun getType ()Ldev/kord/common/entity/ChannelType; + public fun getWebhooks ()Lkotlinx/coroutines/flow/Flow; + public fun hashCode ()I + public fun isNsfw ()Z + public fun startPublicThread (Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun toString ()Ljava/lang/String; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/CategorizableChannelBehavior; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/ChannelBehavior; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/GuildChannelBehavior; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/MediaChannelBehavior; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/TopGuildChannelBehavior; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/channel/threads/ThreadParentChannelBehavior; + 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/channel/CategorizableChannel; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/channel/Channel; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/channel/GuildChannel; + public fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/channel/MediaChannel; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/channel/ThreadParentChannel; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/channel/TopGuildChannel; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel; +} + public abstract interface class dev/kord/core/entity/channel/MessageChannel : dev/kord/core/behavior/channel/MessageChannelBehavior, dev/kord/core/entity/channel/Channel { public abstract fun getLastMessage ()Ldev/kord/core/behavior/MessageBehavior; public abstract fun getLastMessage (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -8959,6 +9091,63 @@ public final class dev/kord/core/entity/channel/thread/ThreadMember : dev/kord/c public fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/channel/thread/ThreadMember; } +public abstract interface class dev/kord/core/entity/channel/thread/ThreadOnlyChannel : dev/kord/core/behavior/channel/threads/ThreadOnlyChannelBehavior, dev/kord/core/entity/channel/ThreadParentChannel { + public abstract fun asChannel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun asChannelOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun equals (Ljava/lang/Object;)Z + public abstract fun getAvailableTags ()Ljava/util/List; + public abstract fun getDefaultAutoArchiveDuration ()Ldev/kord/common/entity/ArchiveDuration; + public abstract fun getDefaultReactionEmoji ()Ldev/kord/common/entity/DefaultReaction; + public abstract fun getDefaultSortOrder ()Ldev/kord/common/entity/SortOrderType; + public abstract fun getDefaultThreadRateLimitPerUser-FghU774 ()Lkotlin/time/Duration; + public abstract fun getLastThreadId ()Ldev/kord/common/entity/Snowflake; + public abstract fun getRateLimitPerUser-FghU774 ()Lkotlin/time/Duration; + public abstract fun getTopic ()Ljava/lang/String; + public abstract fun hashCode ()I + public abstract fun isNsfw ()Z + public abstract fun toString ()Ljava/lang/String; + public abstract fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel; +} + +public final class dev/kord/core/entity/channel/thread/ThreadOnlyChannel$DefaultImpls { + public static fun addOverwrite (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;Ldev/kord/core/entity/PermissionOverwrite;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun compareTo (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;Ldev/kord/core/entity/Entity;)I + public static fun delete (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun fetchChannel (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun fetchChannelOrNull (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getActiveThreads (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Lkotlinx/coroutines/flow/Flow; + public static fun getAvailableTags (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ljava/util/List; + public static fun getCategory (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ldev/kord/core/behavior/channel/CategoryBehavior; + public static fun getCategoryId (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ldev/kord/common/entity/Snowflake; + public static fun getDefaultAutoArchiveDuration (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ldev/kord/common/entity/ArchiveDuration; + public static fun getDefaultReactionEmoji (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ldev/kord/common/entity/DefaultReaction; + public static fun getDefaultSortOrder (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ldev/kord/common/entity/SortOrderType; + public static fun getDefaultThreadRateLimitPerUser-FghU774 (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Lkotlin/time/Duration; + public static fun getEffectivePermissions (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getFlags (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ldev/kord/common/entity/ChannelFlags; + public static fun getGuild (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ldev/kord/core/behavior/GuildBehavior; + public static fun getGuild (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getGuildId (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ldev/kord/common/entity/Snowflake; + public static fun getGuildOrNull (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getId (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ldev/kord/common/entity/Snowflake; + public static fun getInvites (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Lkotlinx/coroutines/flow/Flow; + public static fun getLastThreadId (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ldev/kord/common/entity/Snowflake; + public static fun getMention (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ljava/lang/String; + public static fun getName (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ljava/lang/String; + public static fun getPermissionOverwrites (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ljava/util/Set; + public static fun getPermissionOverwritesForMember (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/entity/PermissionOverwriteEntity; + public static fun getPermissionOverwritesForRole (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/entity/PermissionOverwriteEntity; + public static fun getPosition (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getPublicArchivedThreads (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;Lkotlinx/datetime/Instant;Ljava/lang/Integer;)Lkotlinx/coroutines/flow/Flow; + public static fun getRateLimitPerUser-FghU774 (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Lkotlin/time/Duration; + public static fun getRawPosition (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)I + public static fun getTopic (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ljava/lang/String; + public static fun getType (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Ldev/kord/common/entity/ChannelType; + public static fun getWebhooks (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Lkotlinx/coroutines/flow/Flow; + public static fun isNsfw (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;)Z + public static fun startPublicThread (Ldev/kord/core/entity/channel/thread/ThreadOnlyChannel;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + public final class dev/kord/core/entity/component/ActionRowComponent : dev/kord/core/entity/component/Component { public fun (Ldev/kord/core/cache/data/ComponentData;)V public final fun getComponents ()Ljava/util/List; @@ -11086,6 +11275,41 @@ public final class dev/kord/core/event/channel/ForumChannelUpdateEvent : dev/kor public fun toString ()Ljava/lang/String; } +public final class dev/kord/core/event/channel/MediaChannelCreateEvent : dev/kord/core/event/channel/ChannelCreateEvent { + public fun (Ldev/kord/core/entity/channel/MediaChannel;ILjava/lang/Object;)V + public synthetic fun getChannel ()Ldev/kord/core/entity/channel/Channel; + public fun getChannel ()Ldev/kord/core/entity/channel/MediaChannel; + public fun getCustomContext ()Ljava/lang/Object; + public fun getGateway ()Ldev/kord/gateway/Gateway; + public fun getKord ()Ldev/kord/core/Kord; + public fun getShard ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/kord/core/event/channel/MediaChannelDeleteEvent : dev/kord/core/event/channel/ChannelDeleteEvent { + public fun (Ldev/kord/core/entity/channel/MediaChannel;ILjava/lang/Object;)V + public synthetic fun getChannel ()Ldev/kord/core/entity/channel/Channel; + public fun getChannel ()Ldev/kord/core/entity/channel/MediaChannel; + public fun getCustomContext ()Ljava/lang/Object; + public fun getGateway ()Ldev/kord/gateway/Gateway; + public fun getKord ()Ldev/kord/core/Kord; + public fun getShard ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/kord/core/event/channel/MediaChannelUpdateEvent : dev/kord/core/event/channel/ChannelUpdateEvent { + public fun (Ldev/kord/core/entity/channel/MediaChannel;Ldev/kord/core/entity/channel/MediaChannel;ILjava/lang/Object;)V + public synthetic fun getChannel ()Ldev/kord/core/entity/channel/Channel; + public fun getChannel ()Ldev/kord/core/entity/channel/MediaChannel; + public fun getCustomContext ()Ljava/lang/Object; + public fun getGateway ()Ldev/kord/gateway/Gateway; + public fun getKord ()Ldev/kord/core/Kord; + public synthetic fun getOld ()Ldev/kord/core/entity/channel/Channel; + public fun getOld ()Ldev/kord/core/entity/channel/MediaChannel; + public fun getShard ()I + public fun toString ()Ljava/lang/String; +} + public final class dev/kord/core/event/channel/NewsChannelCreateEvent : dev/kord/core/event/channel/ChannelCreateEvent { public fun (Ldev/kord/core/entity/channel/NewsChannel;ILjava/lang/Object;)V public synthetic fun getChannel ()Ldev/kord/core/entity/channel/Channel; diff --git a/core/src/commonMain/kotlin/Util.kt b/core/src/commonMain/kotlin/Util.kt index a9e729b66343..2522113c50ff 100644 --- a/core/src/commonMain/kotlin/Util.kt +++ b/core/src/commonMain/kotlin/Util.kt @@ -316,6 +316,7 @@ public fun Intents.Builder.enableEvent(event: KClass): Unit = when (e StageChannelCreateEvent::class, TextChannelCreateEvent::class, ForumChannelCreateEvent::class, + MediaChannelCreateEvent::class, UnknownChannelCreateEvent::class, VoiceChannelCreateEvent::class, @@ -326,6 +327,7 @@ public fun Intents.Builder.enableEvent(event: KClass): Unit = when (e StageChannelUpdateEvent::class, TextChannelUpdateEvent::class, ForumChannelUpdateEvent::class, + MediaChannelUpdateEvent::class, UnknownChannelUpdateEvent::class, VoiceChannelUpdateEvent::class, @@ -336,6 +338,7 @@ public fun Intents.Builder.enableEvent(event: KClass): Unit = when (e StageChannelDeleteEvent::class, TextChannelDeleteEvent::class, ForumChannelDeleteEvent::class, + MediaChannelDeleteEvent::class, UnknownChannelDeleteEvent::class, VoiceChannelDeleteEvent::class, diff --git a/core/src/commonMain/kotlin/behavior/GuildBehavior.kt b/core/src/commonMain/kotlin/behavior/GuildBehavior.kt index 242f24240590..be443afa7f0e 100644 --- a/core/src/commonMain/kotlin/behavior/GuildBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/GuildBehavior.kt @@ -777,13 +777,23 @@ public suspend inline fun GuildBehavior.createTextChannel( public suspend inline fun GuildBehavior.createForumChannel( name: String, builder: ForumChannelCreateBuilder.() -> Unit = {} -): ForumChannel { +): ForumChannel { contract { callsInPlace(builder, EXACTLY_ONCE) } val response = kord.rest.guild.createForumChannel(id, name, builder) val data = ChannelData.from(response) return Channel.from(data, kord) as ForumChannel } +public suspend inline fun GuildBehavior.createMediaChannel( + name: String, + builder: MediaChannelCreateBuilder.() -> Unit = {}, +): MediaChannel { + contract { callsInPlace(builder, EXACTLY_ONCE) } + val response = kord.rest.guild.createMediaChannel(id, name, builder) + val data = ChannelData.from(response) + return Channel.from(data, kord) as MediaChannel +} + /** * Requests to create a new voice channel. * diff --git a/core/src/commonMain/kotlin/behavior/channel/ForumChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/ForumChannelBehavior.kt index cc633399bae6..e8360edfe2cd 100644 --- a/core/src/commonMain/kotlin/behavior/channel/ForumChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/ForumChannelBehavior.kt @@ -1,38 +1,19 @@ package dev.kord.core.behavior.channel import dev.kord.common.exception.RequestException -import dev.kord.core.behavior.channel.threads.ThreadParentChannelBehavior +import dev.kord.core.behavior.channel.threads.ThreadOnlyChannelBehavior import dev.kord.core.cache.data.ChannelData import dev.kord.core.entity.channel.Channel import dev.kord.core.entity.channel.ForumChannel -import dev.kord.core.entity.channel.thread.TextChannelThread import dev.kord.core.exception.EntityNotFoundException import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.rest.builder.channel.ForumChannelModifyBuilder -import dev.kord.rest.builder.channel.thread.StartForumThreadBuilder import dev.kord.rest.service.patchForumChannel -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.filterIsInstance -import kotlinx.datetime.Instant import kotlin.contracts.InvocationKind import kotlin.contracts.contract -public interface ForumChannelBehavior : ThreadParentChannelBehavior { - - override val activeThreads: Flow - get() = super.activeThreads.filterIsInstance() - - override fun getPublicArchivedThreads(before: Instant?, limit: Int?): Flow { - return super.getPublicArchivedThreads(before, limit).filterIsInstance() - } - - public suspend fun startPublicThread( - name: String, - builder: StartForumThreadBuilder.() -> Unit, - ): TextChannelThread { - return unsafeStartForumThread(name, builder) - } +public interface ForumChannelBehavior : ThreadOnlyChannelBehavior { /** * Requests to get this behavior as a [ForumChannel]. @@ -52,7 +33,7 @@ public interface ForumChannelBehavior : ThreadParentChannelBehavior { override suspend fun asChannelOrNull(): ForumChannel? = super.asChannelOrNull() as? ForumChannel /** - * Retrieve the [ForumChannel] associated with this behaviour from the provided [EntitySupplier]. + * Retrieve the [ForumChannel] associated with this behavior from the provided [EntitySupplier]. * * @throws RequestException if anything went wrong during the request. * @throws EntityNotFoundException if the user wasn't present. @@ -60,7 +41,7 @@ public interface ForumChannelBehavior : ThreadParentChannelBehavior { override suspend fun fetchChannel(): ForumChannel = super.fetchChannel() as ForumChannel /** - * Retrieve the [ForumChannel] associated with this behaviour from the provided [EntitySupplier] + * Retrieve the [ForumChannel] associated with this behavior from the provided [EntitySupplier] * returns null if the [ForumChannel] isn't present. * * @throws RequestException if anything went wrong during the request. @@ -70,18 +51,6 @@ public interface ForumChannelBehavior : ThreadParentChannelBehavior { override fun withStrategy(strategy: EntitySupplyStrategy<*>): ForumChannelBehavior } -internal suspend fun ThreadParentChannelBehavior.unsafeStartForumThread( - name: String, - builder: StartForumThreadBuilder.() -> Unit, -): TextChannelThread { - contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } - - val response = kord.rest.channel.startForumThread(id, name, builder) - val data = ChannelData.from(response) - - return Channel.from(data, kord) as TextChannelThread -} - public suspend inline fun ForumChannelBehavior.edit(builder: ForumChannelModifyBuilder.() -> Unit): ForumChannel { contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } diff --git a/core/src/commonMain/kotlin/behavior/channel/MediaChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/MediaChannelBehavior.kt new file mode 100644 index 000000000000..52d24627e14e --- /dev/null +++ b/core/src/commonMain/kotlin/behavior/channel/MediaChannelBehavior.kt @@ -0,0 +1,61 @@ +package dev.kord.core.behavior.channel + +import dev.kord.common.exception.RequestException +import dev.kord.core.behavior.channel.threads.ThreadOnlyChannelBehavior +import dev.kord.core.cache.data.ChannelData +import dev.kord.core.entity.channel.Channel +import dev.kord.core.entity.channel.MediaChannel +import dev.kord.core.exception.EntityNotFoundException +import dev.kord.core.supplier.EntitySupplier +import dev.kord.core.supplier.EntitySupplyStrategy +import dev.kord.rest.builder.channel.MediaChannelModifyBuilder +import dev.kord.rest.service.patchMediaChannel +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract + +public interface MediaChannelBehavior : ThreadOnlyChannelBehavior { + + /** + * Requests to get this behavior as a [MediaChannel]. + * + * @throws RequestException if anything went wrong during the request. + * @throws EntityNotFoundException if the channel wasn't present. + * @throws ClassCastException if the channel isn't a [MediaChannel]. + */ + override suspend fun asChannel(): MediaChannel = super.asChannel() as MediaChannel + + /** + * Requests to get this behavior as a [MediaChannel], + * returns null if the channel isn't present or if the channel isn't a [MediaChannel]. + * + * @throws RequestException if anything went wrong during the request. + */ + override suspend fun asChannelOrNull(): MediaChannel? = super.asChannelOrNull() as? MediaChannel + + /** + * Retrieve the [MediaChannel] associated with this behavior from the provided [EntitySupplier]. + * + * @throws RequestException if anything went wrong during the request. + * @throws EntityNotFoundException if the user wasn't present. + */ + override suspend fun fetchChannel(): MediaChannel = super.fetchChannel() as MediaChannel + + /** + * Retrieve the [MediaChannel] associated with this behavior from the provided [EntitySupplier] + * returns null if the [MediaChannel] isn't present. + * + * @throws RequestException if anything went wrong during the request. + */ + override suspend fun fetchChannelOrNull(): MediaChannel? = super.fetchChannelOrNull() as? MediaChannel + + override fun withStrategy(strategy: EntitySupplyStrategy<*>): MediaChannelBehavior +} + +public suspend inline fun MediaChannelBehavior.edit(builder: MediaChannelModifyBuilder.() -> Unit): MediaChannel { + contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } + + val response = kord.rest.channel.patchMediaChannel(id, builder) + val data = ChannelData.from(response) + + return Channel.from(data, kord) as MediaChannel +} diff --git a/core/src/commonMain/kotlin/behavior/channel/threads/ThreadOnlyChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/threads/ThreadOnlyChannelBehavior.kt new file mode 100644 index 000000000000..cd0ad024d822 --- /dev/null +++ b/core/src/commonMain/kotlin/behavior/channel/threads/ThreadOnlyChannelBehavior.kt @@ -0,0 +1,74 @@ +package dev.kord.core.behavior.channel.threads + +import dev.kord.common.exception.RequestException +import dev.kord.core.cache.data.ChannelData +import dev.kord.core.entity.channel.Channel +import dev.kord.core.entity.channel.thread.ThreadOnlyChannel +import dev.kord.core.entity.channel.thread.TextChannelThread +import dev.kord.core.exception.EntityNotFoundException +import dev.kord.core.supplier.EntitySupplier +import dev.kord.core.supplier.EntitySupplyStrategy +import dev.kord.rest.builder.channel.thread.StartForumThreadBuilder +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.filterIsInstance +import kotlinx.datetime.Instant +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract + +public interface ThreadOnlyChannelBehavior : ThreadParentChannelBehavior { + + override val activeThreads: Flow get() = super.activeThreads.filterIsInstance() + + override fun getPublicArchivedThreads(before: Instant?, limit: Int?): Flow = + super.getPublicArchivedThreads(before, limit).filterIsInstance() + + public suspend fun startPublicThread(name: String, builder: StartForumThreadBuilder.() -> Unit): TextChannelThread = + unsafeStartThreadInThreadOnlyChannel(name, builder) + + /** + * Requests to get this behavior as a [ThreadOnlyChannel]. + * + * @throws RequestException if anything went wrong during the request. + * @throws EntityNotFoundException if the channel wasn't present. + * @throws ClassCastException if the channel isn't a [ThreadOnlyChannel]. + */ + override suspend fun asChannel(): ThreadOnlyChannel = super.asChannel() as ThreadOnlyChannel + + /** + * Requests to get this behavior as a [ThreadOnlyChannel], + * returns null if the channel isn't present or if the channel isn't a [ThreadOnlyChannel]. + * + * @throws RequestException if anything went wrong during the request. + */ + override suspend fun asChannelOrNull(): ThreadOnlyChannel? = super.asChannelOrNull() as? ThreadOnlyChannel + + /** + * Retrieve the [ThreadOnlyChannel] associated with this behavior from the provided [EntitySupplier]. + * + * @throws RequestException if anything went wrong during the request. + * @throws EntityNotFoundException if the user wasn't present. + */ + override suspend fun fetchChannel(): ThreadOnlyChannel = super.fetchChannel() as ThreadOnlyChannel + + /** + * Retrieve the [ThreadOnlyChannel] associated with this behavior from the provided [EntitySupplier] + * returns null if the [ThreadOnlyChannel] isn't present. + * + * @throws RequestException if anything went wrong during the request. + */ + override suspend fun fetchChannelOrNull(): ThreadOnlyChannel? = super.fetchChannelOrNull() as? ThreadOnlyChannel + + override fun withStrategy(strategy: EntitySupplyStrategy<*>): ThreadOnlyChannelBehavior +} + +internal suspend fun ThreadParentChannelBehavior.unsafeStartThreadInThreadOnlyChannel( + name: String, + builder: StartForumThreadBuilder.() -> Unit, +): TextChannelThread { + contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } + + val response = kord.rest.channel.startForumThread(id, name, builder) + val data = ChannelData.from(response) + + return Channel.from(data, kord) as TextChannelThread +} diff --git a/core/src/commonMain/kotlin/entity/channel/Channel.kt b/core/src/commonMain/kotlin/entity/channel/Channel.kt index ed67805c9f3b..57f7933d3c35 100644 --- a/core/src/commonMain/kotlin/entity/channel/Channel.kt +++ b/core/src/commonMain/kotlin/entity/channel/Channel.kt @@ -47,25 +47,24 @@ public interface Channel : ChannelBehavior { kord: Kord, strategy: EntitySupplyStrategy<*> = kord.resources.defaultStrategy ): Channel = when (data.type) { - GuildText -> TextChannel(data, kord) - DM, GroupDM -> DmChannel(data, kord) - GuildStageVoice -> StageChannel(data, kord) - GuildVoice -> VoiceChannel(data, kord) - GuildCategory -> Category(data, kord) - GuildNews -> NewsChannel(data, kord) - GuildForum -> ForumChannel(data, kord) - PublicNewsThread -> NewsChannelThread(data, kord) - PrivateThread, PublicGuildThread -> { - TextChannelThread(data, kord) - } + GuildText -> TextChannel(data, kord) + DM, GroupDM -> DmChannel(data, kord) + GuildStageVoice -> StageChannel(data, kord) + GuildVoice -> VoiceChannel(data, kord) + GuildCategory -> Category(data, kord) + GuildNews -> NewsChannel(data, kord) + GuildForum -> ForumChannel(data, kord) + GuildMedia -> MediaChannel(data, kord) + PublicNewsThread -> NewsChannelThread(data, kord) + PrivateThread, PublicGuildThread -> TextChannelThread(data, kord) - GuildDirectory, is Unknown -> { - if (data.threadMetadata.value == null) Channel(data, kord, strategy.supply(kord)) - else ThreadChannel(data, kord, strategy.supply(kord)) - } + GuildDirectory, is Unknown -> { + if (data.threadMetadata.value == null) Channel(data, kord, strategy.supply(kord)) + else ThreadChannel(data, kord, strategy.supply(kord)) } } } +} internal fun Channel( diff --git a/core/src/commonMain/kotlin/entity/channel/ForumChannel.kt b/core/src/commonMain/kotlin/entity/channel/ForumChannel.kt index e2acb0121680..92fed75f354d 100644 --- a/core/src/commonMain/kotlin/entity/channel/ForumChannel.kt +++ b/core/src/commonMain/kotlin/entity/channel/ForumChannel.kt @@ -1,46 +1,20 @@ package dev.kord.core.entity.channel -import dev.kord.common.entity.* -import dev.kord.common.entity.Permission.ManageChannels -import dev.kord.common.entity.Permission.ManageMessages +import dev.kord.common.entity.ForumLayoutType import dev.kord.core.Kord import dev.kord.core.behavior.channel.ForumChannelBehavior +import dev.kord.core.behavior.channel.GuildChannelBehavior import dev.kord.core.cache.data.ChannelData +import dev.kord.core.entity.channel.thread.ThreadOnlyChannel +import dev.kord.core.hash import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy -import kotlin.time.Duration public class ForumChannel( override val data: ChannelData, override val kord: Kord, override val supplier: EntitySupplier = kord.defaultSupplier -) : ThreadParentChannel, ForumChannelBehavior { - - /** - * The channel topic, if present. - */ - public val topic: String? get() = data.topic.value - - /** Whether the channel is nsfw. */ - public val isNsfw: Boolean get() = data.nsfw.orElse(false) - - public val availableTags: List get() = data.availableTags.value ?: emptyList() - - public val defaultReactionEmoji: DefaultReaction? get() = data.defaultReactionEmoji.value - - /** - * The amount of time a user has to wait before creating another thread. - * - * Bots, as well as users with the permission [ManageMessages] or [ManageChannels], are unaffected. - */ - public val rateLimitPerUser: Duration? get() = data.rateLimitPerUser.value - - public val defaultThreadRateLimitPerUser: Duration? get() = data.defaultThreadRateLimitPerUser.value - - public val defaultAutoArchiveDuration: ArchiveDuration? get() = data.defaultAutoArchiveDuration.value - - /** The default sort order type used to order posts in this forum channel. */ - public val defaultSortOrder: SortOrderType? get() = data.defaultSortOrder.value +) : ThreadOnlyChannel, ForumChannelBehavior { /** * The default layout of the forum, if present. @@ -52,5 +26,9 @@ public class ForumChannel( override fun withStrategy(strategy: EntitySupplyStrategy<*>): ForumChannel = ForumChannel(data, kord, strategy.supply(kord)) + override fun equals(other: Any?): Boolean = + other is GuildChannelBehavior && this.id == other.id && this.guildId == other.guildId + + override fun hashCode(): Int = hash(id, guildId) override fun toString(): String = "ForumChannel(data=$data, kord=$kord, supplier=$supplier)" } diff --git a/core/src/commonMain/kotlin/entity/channel/MediaChannel.kt b/core/src/commonMain/kotlin/entity/channel/MediaChannel.kt new file mode 100644 index 000000000000..01c2abab3d08 --- /dev/null +++ b/core/src/commonMain/kotlin/entity/channel/MediaChannel.kt @@ -0,0 +1,28 @@ +package dev.kord.core.entity.channel + +import dev.kord.core.Kord +import dev.kord.core.behavior.channel.GuildChannelBehavior +import dev.kord.core.behavior.channel.MediaChannelBehavior +import dev.kord.core.cache.data.ChannelData +import dev.kord.core.entity.channel.thread.ThreadOnlyChannel +import dev.kord.core.hash +import dev.kord.core.supplier.EntitySupplier +import dev.kord.core.supplier.EntitySupplyStrategy + +public class MediaChannel( + override val data: ChannelData, + override val kord: Kord, + override val supplier: EntitySupplier = kord.defaultSupplier, +) : ThreadOnlyChannel, MediaChannelBehavior { + + override suspend fun asChannel(): MediaChannel = this + override suspend fun asChannelOrNull(): MediaChannel = this + override fun withStrategy(strategy: EntitySupplyStrategy<*>): MediaChannel = + MediaChannel(data, kord, strategy.supply(kord)) + + override fun equals(other: Any?): Boolean = + other is GuildChannelBehavior && this.id == other.id && this.guildId == other.guildId + + override fun hashCode(): Int = hash(id, guildId) + override fun toString(): String = "MediaChannel(data=$data, kord=$kord, supplier=$supplier)" +} diff --git a/core/src/commonMain/kotlin/entity/channel/thread/ThreadChannel.kt b/core/src/commonMain/kotlin/entity/channel/thread/ThreadChannel.kt index dd8353ab4c9a..decba0cb73fb 100644 --- a/core/src/commonMain/kotlin/entity/channel/thread/ThreadChannel.kt +++ b/core/src/commonMain/kotlin/entity/channel/thread/ThreadChannel.kt @@ -12,7 +12,9 @@ import dev.kord.core.behavior.UserBehavior import dev.kord.core.behavior.channel.threads.ThreadChannelBehavior import dev.kord.core.cache.data.ChannelData import dev.kord.core.entity.Message +import dev.kord.core.entity.channel.ForumChannel import dev.kord.core.entity.channel.GuildMessageChannel +import dev.kord.core.entity.channel.MediaChannel import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import kotlinx.datetime.Instant @@ -113,12 +115,12 @@ public interface ThreadChannel : GuildMessageChannel, ThreadChannelBehavior { /** - * Only available when creating a thread in a forum channel + * Only available when creating a thread in a [ForumChannel] or [MediaChannel]. */ public val message: Message? get() = data.message.unwrap { Message(it, kord) } /** - * Only available when creating a thread in a forum channel + * Only available when creating a thread in a [ForumChannel] or [MediaChannel]. */ public val appliedTags: List get() = data.appliedTags.value ?: emptyList() diff --git a/core/src/commonMain/kotlin/entity/channel/thread/ThreadOnlyChannel.kt b/core/src/commonMain/kotlin/entity/channel/thread/ThreadOnlyChannel.kt new file mode 100644 index 000000000000..de15de7ff0a4 --- /dev/null +++ b/core/src/commonMain/kotlin/entity/channel/thread/ThreadOnlyChannel.kt @@ -0,0 +1,57 @@ +package dev.kord.core.entity.channel.thread + +import dev.kord.common.entity.* +import dev.kord.common.entity.Permission.ManageChannels +import dev.kord.common.entity.Permission.ManageMessages +import dev.kord.core.behavior.channel.threads.ThreadOnlyChannelBehavior +import dev.kord.core.entity.channel.ThreadParentChannel +import dev.kord.core.supplier.EntitySupplyStrategy +import kotlin.time.Duration + +public interface ThreadOnlyChannel : ThreadParentChannel, ThreadOnlyChannelBehavior { + + /** The channel topic, if present. */ + public val topic: String? get() = data.topic.value + + /** Whether the channel is nsfw. */ + public val isNsfw: Boolean get() = data.nsfw.orElse(false) + + /** The id of the last thread created in this channel (may not point to an existing or valid thread). */ + public val lastThreadId: Snowflake? get() = data.lastMessageId?.value + + /** + * The amount of time a user has to wait before creating another thread. + * + * Bots, as well as users with the permission [ManageMessages] or [ManageChannels], are unaffected. + */ + public val rateLimitPerUser: Duration? get() = data.rateLimitPerUser.value + + /** + * Default [ArchiveDuration], copied onto newly created threads in this channel. Threads will stop showing in the + * channel list after the specified period of inactivity. + */ + public val defaultAutoArchiveDuration: ArchiveDuration? get() = data.defaultAutoArchiveDuration.value + + /** The set of tags that can be used in this channel. */ + public val availableTags: List get() = data.availableTags.value ?: emptyList() + + /** The emoji to show in the add reaction button on a thread in this channel. */ + public val defaultReactionEmoji: DefaultReaction? get() = data.defaultReactionEmoji.value + + /** + * The initial [ThreadChannel.rateLimitPerUser] to set on newly created threads in this channel. This field is + * copied to the thread at creation time and does not live update. + */ + public val defaultThreadRateLimitPerUser: Duration? get() = data.defaultThreadRateLimitPerUser.value + + /** The default [SortOrderType] used to order posts in this channel. */ + public val defaultSortOrder: SortOrderType? get() = data.defaultSortOrder.value + + override suspend fun asChannel(): ThreadOnlyChannel + override suspend fun asChannelOrNull(): ThreadOnlyChannel + override fun withStrategy(strategy: EntitySupplyStrategy<*>): ThreadOnlyChannel + + override fun equals(other: Any?): Boolean + override fun hashCode(): Int + override fun toString(): String +} diff --git a/core/src/commonMain/kotlin/event/channel/ChannelCreateEvent.kt b/core/src/commonMain/kotlin/event/channel/ChannelCreateEvent.kt index e504dae7b707..f4f64afbc3a6 100644 --- a/core/src/commonMain/kotlin/event/channel/ChannelCreateEvent.kt +++ b/core/src/commonMain/kotlin/event/channel/ChannelCreateEvent.kt @@ -73,13 +73,21 @@ public class StageChannelCreateEvent( public class ForumChannelCreateEvent( override val channel: ForumChannel, - override val shard : Int, + override val shard: Int, override val customContext: Any?, +) : ChannelCreateEvent { + override fun toString(): String { + return "ForumChannelCreateEvent(channel=$channel, shard=$shard)" + } +} +public class MediaChannelCreateEvent( + override val channel: MediaChannel, + override val shard: Int, + override val customContext: Any?, ) : ChannelCreateEvent { - override fun toString(): String { - return "ForumChannelCreateEvent(channel=$channel, shard=$shard)" - } + override fun toString(): String = + "MediaChannelCreateEvent(channel=$channel, shard=$shard, customContext=$customContext)" } public class UnknownChannelCreateEvent( diff --git a/core/src/commonMain/kotlin/event/channel/ChannelDeleteEvent.kt b/core/src/commonMain/kotlin/event/channel/ChannelDeleteEvent.kt index 4cee2e8a050d..2ee13d2a6ba4 100644 --- a/core/src/commonMain/kotlin/event/channel/ChannelDeleteEvent.kt +++ b/core/src/commonMain/kotlin/event/channel/ChannelDeleteEvent.kt @@ -80,6 +80,14 @@ public class ForumChannelDeleteEvent( } } +public class MediaChannelDeleteEvent( + override val channel: MediaChannel, + override val shard: Int, + override val customContext: Any?, +) : ChannelDeleteEvent { + override fun toString(): String = + "MediaChannelDeleteEvent(channel=$channel, shard=$shard, customContext=$customContext)" +} public class UnknownChannelDeleteEvent( override val channel: Channel, diff --git a/core/src/commonMain/kotlin/event/channel/ChannelUpdateEvent.kt b/core/src/commonMain/kotlin/event/channel/ChannelUpdateEvent.kt index 08f030c89216..8e2de0c7b447 100644 --- a/core/src/commonMain/kotlin/event/channel/ChannelUpdateEvent.kt +++ b/core/src/commonMain/kotlin/event/channel/ChannelUpdateEvent.kt @@ -90,6 +90,15 @@ public class ForumChannelUpdateEvent( } } +public class MediaChannelUpdateEvent( + override val channel: MediaChannel, + override val old: MediaChannel?, + override val shard: Int, + override val customContext: Any?, +) : ChannelUpdateEvent { + override fun toString(): String = + "MediaChannelUpdateEvent(channel=$channel, old=$old, shard=$shard, customContext=$customContext)" +} public class UnknownChannelUpdateEvent( override val channel: Channel, diff --git a/core/src/commonMain/kotlin/gateway/handler/ChannelEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/ChannelEventHandler.kt index 37d2b3f9c4a4..5f68b76ac3b8 100644 --- a/core/src/commonMain/kotlin/gateway/handler/ChannelEventHandler.kt +++ b/core/src/commonMain/kotlin/gateway/handler/ChannelEventHandler.kt @@ -42,6 +42,7 @@ internal class ChannelEventHandler : BaseGatewayEventHandler() { is VoiceChannel -> VoiceChannelCreateEvent(channel, shard, context?.get()) is Category -> CategoryCreateEvent(channel, shard, context?.get()) is ForumChannel -> ForumChannelCreateEvent(channel, shard, context?.get()) + is MediaChannel -> MediaChannelCreateEvent(channel, shard, context?.get()) is ThreadChannel -> return null else -> UnknownChannelCreateEvent(channel, shard, context?.get()) @@ -63,6 +64,7 @@ internal class ChannelEventHandler : BaseGatewayEventHandler() { is VoiceChannel -> VoiceChannelUpdateEvent(channel, old as? VoiceChannel, shard, context?.get()) is Category -> CategoryUpdateEvent(channel, old as? Category, shard, context?.get()) is ForumChannel -> ForumChannelUpdateEvent(channel, old as? ForumChannel, shard, context?.get()) + is MediaChannel -> MediaChannelUpdateEvent(channel, old as? MediaChannel, shard, context?.get()) is ThreadChannel -> return null else -> UnknownChannelUpdateEvent(channel, old, shard, context?.get()) @@ -83,6 +85,7 @@ internal class ChannelEventHandler : BaseGatewayEventHandler() { is VoiceChannel -> VoiceChannelDeleteEvent(channel, shard, context?.get()) is Category -> CategoryDeleteEvent(channel, shard, context?.get()) is ForumChannel -> ForumChannelDeleteEvent(channel, shard, context?.get()) + is MediaChannel -> MediaChannelDeleteEvent(channel, shard, context?.get()) is ThreadChannel -> return null else -> UnknownChannelDeleteEvent(channel, shard, context?.get()) } diff --git a/core/src/commonMain/kotlin/gateway/handler/ThreadEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/ThreadEventHandler.kt index 08ffcb061ef1..f1cee173a2ef 100644 --- a/core/src/commonMain/kotlin/gateway/handler/ThreadEventHandler.kt +++ b/core/src/commonMain/kotlin/gateway/handler/ThreadEventHandler.kt @@ -35,11 +35,11 @@ internal class ThreadEventHandler : BaseGatewayEventHandler() { val channelData = event.channel.toData() kord.cache.put(channelData) - // update lastMessageId for forum channels when thread is created + // update lastMessageId for forum and media channels when thread is created // (same for other channels when message is created) val parentId = channelData.parentId?.value!! kord.cache.query { - ChannelData::type eq ChannelType.GuildForum + ChannelData::type predicate { it == ChannelType.GuildForum || it == ChannelType.GuildMedia } idEq(ChannelData::id, parentId) }.update { it.copy(lastMessageId = channelData.id.optionalSnowflake()) diff --git a/ksp-annotations/src/commonMain/kotlin/Generate.kt b/ksp-annotations/src/commonMain/kotlin/Generate.kt index e148b7fabeea..9ffe7caccf35 100644 --- a/ksp-annotations/src/commonMain/kotlin/Generate.kt +++ b/ksp-annotations/src/commonMain/kotlin/Generate.kt @@ -49,5 +49,8 @@ annotation class Generate( val deprecated: Deprecated = Deprecated(""), /** [RequiresOptIn] annotations to add to this entry. */ val requiresOptInAnnotations: Array = [], + + // for migration only, will be removed eventually + val noStaticFieldIfEntityWasEnum: Boolean = false, ) } diff --git a/ksp-processors/src/main/kotlin/generation/GenerationEntity.kt b/ksp-processors/src/main/kotlin/generation/GenerationEntity.kt index c777b258b162..d90d8dbc0668 100644 --- a/ksp-processors/src/main/kotlin/generation/GenerationEntity.kt +++ b/ksp-processors/src/main/kotlin/generation/GenerationEntity.kt @@ -48,6 +48,7 @@ internal sealed class GenerationEntity( val value: Comparable<*>, val deprecated: Deprecated?, val requiresOptInAnnotations: List, + val noStaticFieldIfEntityWasEnum: Boolean, ) } @@ -159,5 +160,6 @@ private fun Entry.toGenerationEntityEntryOrNull( } else { requiresOptInAnnotations.toList() }, + noStaticFieldIfEntityWasEnum, ) } diff --git a/ksp-processors/src/main/kotlin/generation/bitflags/EnumArtifacts.kt b/ksp-processors/src/main/kotlin/generation/bitflags/EnumArtifacts.kt index f6060b10104c..460ce8e28104 100644 --- a/ksp-processors/src/main/kotlin/generation/bitflags/EnumArtifacts.kt +++ b/ksp-processors/src/main/kotlin/generation/bitflags/EnumArtifacts.kt @@ -67,6 +67,7 @@ context(BitFlags, GenerationContext) @OptIn(DelicateKotlinPoetApi::class) internal fun TypeSpec.Builder.addDeprecatedEntityCompanionObjectEnumArtifacts() { entries.forEach { entry -> + if (entry.noStaticFieldIfEntityWasEnum) return@forEach addProperty(entry.name, entityCN) { when (entry.deprecated?.level) { null -> {} diff --git a/rest/api/rest.api b/rest/api/rest.api index 96cc14dc4c07..9eb9c02aff4c 100644 --- a/rest/api/rest.api +++ b/rest/api/rest.api @@ -592,6 +592,88 @@ public final class dev/kord/rest/builder/channel/InviteCreateBuilder : dev/kord/ public synthetic fun toRequest ()Ljava/lang/Object; } +public final class dev/kord/rest/builder/channel/MediaChannelCreateBuilder : dev/kord/rest/builder/AuditRequestBuilder, dev/kord/rest/builder/channel/PermissionOverwritesCreateBuilder { + public fun (Ljava/lang/String;)V + public fun addOverwrite (Ldev/kord/common/entity/Overwrite;)V + public final fun getAvailableTags ()Ljava/util/List; + public final fun getDefaultAutoArchiveDuration ()Ldev/kord/common/entity/ArchiveDuration; + public final fun getDefaultReactionEmoji ()Ldev/kord/common/entity/DefaultReaction; + public final fun getDefaultReactionEmojiId ()Ldev/kord/common/entity/Snowflake; + public final fun getDefaultReactionEmojiName ()Ljava/lang/String; + public final fun getDefaultSortOrder ()Ldev/kord/common/entity/SortOrderType; + public final fun getDefaultThreadRateLimitPerUser-FghU774 ()Lkotlin/time/Duration; + public final fun getFlags ()Ldev/kord/common/entity/ChannelFlags; + public final fun getName ()Ljava/lang/String; + public final fun getNsfw ()Ljava/lang/Boolean; + public final fun getParentId ()Ldev/kord/common/entity/Snowflake; + public fun getPermissionOverwrites ()Ljava/util/Set; + public final fun getPosition ()Ljava/lang/Integer; + public final fun getRateLimitPerUser-FghU774 ()Lkotlin/time/Duration; + public fun getReason ()Ljava/lang/String; + public final fun getTopic ()Ljava/lang/String; + public final fun setAvailableTags (Ljava/util/List;)V + public final fun setDefaultAutoArchiveDuration (Ldev/kord/common/entity/ArchiveDuration;)V + public final fun setDefaultReactionEmoji (Ldev/kord/common/entity/DefaultReaction;)V + public final fun setDefaultReactionEmojiId (Ldev/kord/common/entity/Snowflake;)V + public final fun setDefaultReactionEmojiName (Ljava/lang/String;)V + public final fun setDefaultSortOrder (Ldev/kord/common/entity/SortOrderType;)V + public final fun setDefaultThreadRateLimitPerUser-BwNAW2A (Lkotlin/time/Duration;)V + public final fun setFlags (Ldev/kord/common/entity/ChannelFlags;)V + public final fun setName (Ljava/lang/String;)V + public final fun setNsfw (Ljava/lang/Boolean;)V + public final fun setParentId (Ldev/kord/common/entity/Snowflake;)V + public fun setPermissionOverwrites (Ljava/util/Set;)V + public final fun setPosition (Ljava/lang/Integer;)V + public final fun setRateLimitPerUser-BwNAW2A (Lkotlin/time/Duration;)V + public fun setReason (Ljava/lang/String;)V + public final fun setTopic (Ljava/lang/String;)V + public final fun tag (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V + public static synthetic fun tag$default (Ldev/kord/rest/builder/channel/MediaChannelCreateBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V + public fun toRequest ()Ldev/kord/rest/json/request/GuildChannelCreateRequest; + public synthetic fun toRequest ()Ljava/lang/Object; +} + +public final class dev/kord/rest/builder/channel/MediaChannelModifyBuilder : dev/kord/rest/builder/AuditRequestBuilder, dev/kord/rest/builder/channel/PermissionOverwritesModifyBuilder { + public fun ()V + public fun addOverwrite (Ldev/kord/common/entity/Overwrite;)V + public final fun getAvailableTags ()Ljava/util/List; + public final fun getDefaultAutoArchiveDuration ()Ldev/kord/common/entity/ArchiveDuration; + public final fun getDefaultReactionEmoji ()Ldev/kord/common/entity/DefaultReaction; + public final fun getDefaultReactionEmojiId ()Ldev/kord/common/entity/Snowflake; + public final fun getDefaultReactionEmojiName ()Ljava/lang/String; + public final fun getDefaultSortOrder ()Ldev/kord/common/entity/SortOrderType; + public final fun getDefaultThreadRateLimitPerUser-FghU774 ()Lkotlin/time/Duration; + public final fun getFlags ()Ldev/kord/common/entity/ChannelFlags; + public final fun getName ()Ljava/lang/String; + public final fun getNsfw ()Ljava/lang/Boolean; + public final fun getParentId ()Ldev/kord/common/entity/Snowflake; + public fun getPermissionOverwrites ()Ljava/util/Set; + public final fun getPosition ()Ljava/lang/Integer; + public final fun getRateLimitPerUser-FghU774 ()Lkotlin/time/Duration; + public fun getReason ()Ljava/lang/String; + public final fun getTopic ()Ljava/lang/String; + public final fun setAvailableTags (Ljava/util/List;)V + public final fun setDefaultAutoArchiveDuration (Ldev/kord/common/entity/ArchiveDuration;)V + public final fun setDefaultReactionEmoji (Ldev/kord/common/entity/DefaultReaction;)V + public final fun setDefaultReactionEmojiId (Ldev/kord/common/entity/Snowflake;)V + public final fun setDefaultReactionEmojiName (Ljava/lang/String;)V + public final fun setDefaultSortOrder (Ldev/kord/common/entity/SortOrderType;)V + public final fun setDefaultThreadRateLimitPerUser-BwNAW2A (Lkotlin/time/Duration;)V + public final fun setFlags (Ldev/kord/common/entity/ChannelFlags;)V + public final fun setName (Ljava/lang/String;)V + public final fun setNsfw (Ljava/lang/Boolean;)V + public final fun setParentId (Ldev/kord/common/entity/Snowflake;)V + public fun setPermissionOverwrites (Ljava/util/Set;)V + public final fun setPosition (Ljava/lang/Integer;)V + public final fun setRateLimitPerUser-BwNAW2A (Lkotlin/time/Duration;)V + public fun setReason (Ljava/lang/String;)V + public final fun setTopic (Ljava/lang/String;)V + public final fun tag (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V + public static synthetic fun tag$default (Ldev/kord/rest/builder/channel/MediaChannelModifyBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V + public fun toRequest ()Ldev/kord/rest/json/request/ChannelModifyPatchRequest; + public synthetic fun toRequest ()Ljava/lang/Object; +} + public final class dev/kord/rest/builder/channel/NewsChannelCreateBuilder : dev/kord/rest/builder/AuditRequestBuilder, dev/kord/rest/builder/channel/PermissionOverwritesCreateBuilder { public fun (Ljava/lang/String;)V public fun addOverwrite (Ldev/kord/common/entity/Overwrite;)V @@ -1108,6 +1190,8 @@ public final class dev/kord/rest/builder/guild/GuildCreateBuilder : dev/kord/res public final fun getSnowflakeGenerator ()Ljava/util/Iterator; public final fun getSystemChannelId ()Ldev/kord/common/entity/Snowflake; public final fun getVerificationLevel ()Ldev/kord/common/entity/VerificationLevel; + public final fun mediaChannel (Ljava/lang/String;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;)Ldev/kord/common/entity/Snowflake; + public static synthetic fun mediaChannel$default (Ldev/kord/rest/builder/guild/GuildCreateBuilder;Ljava/lang/String;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/kord/common/entity/Snowflake; public final fun newUniqueSnowflake ()Ldev/kord/common/entity/Snowflake; public final fun newsChannel (Ljava/lang/String;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;)Ldev/kord/common/entity/Snowflake; public static synthetic fun newsChannel$default (Ldev/kord/rest/builder/guild/GuildCreateBuilder;Ljava/lang/String;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/kord/common/entity/Snowflake; @@ -7185,6 +7269,7 @@ public final class dev/kord/rest/service/ChannelServiceKt { public static final fun editRolePermission (Ldev/kord/rest/service/ChannelService;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun patchCategory (Ldev/kord/rest/service/ChannelService;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun patchForumChannel (Ldev/kord/rest/service/ChannelService;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun patchMediaChannel (Ldev/kord/rest/service/ChannelService;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun patchNewsChannel (Ldev/kord/rest/service/ChannelService;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun patchStageVoiceChannel (Ldev/kord/rest/service/ChannelService;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun patchTextChannel (Ldev/kord/rest/service/ChannelService;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -7289,6 +7374,7 @@ public final class dev/kord/rest/service/GuildService : dev/kord/rest/service/Re public final class dev/kord/rest/service/GuildServiceKt { public static final fun createCategory (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun createForumChannel (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun createMediaChannel (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun createNewsChannel (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun createScheduledEvent (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/GuildScheduledEventPrivacyLevel;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/ScheduledEntityType;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun createScheduledEvent$default (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/GuildScheduledEventPrivacyLevel;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/ScheduledEntityType;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; diff --git a/rest/src/commonMain/kotlin/builder/channel/EditGuildChannelBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/EditGuildChannelBuilder.kt index 99c46dcf48ae..6797454ee60b 100644 --- a/rest/src/commonMain/kotlin/builder/channel/EditGuildChannelBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/channel/EditGuildChannelBuilder.kt @@ -150,6 +150,87 @@ public class ForumChannelModifyBuilder : PermissionOverwritesModifyBuilder, } +@KordDsl +public class MediaChannelModifyBuilder : PermissionOverwritesModifyBuilder, + AuditRequestBuilder { + override var reason: String? = null + + private var _name: Optional = Optional.Missing() + public var name: String? by ::_name.delegate() + + private var _position: OptionalInt? = OptionalInt.Missing + public var position: Int? by ::_position.delegate() + + private var _topic: Optional = Optional.Missing() + public var topic: String? by ::_topic.delegate() + + private var _nsfw: OptionalBoolean? = OptionalBoolean.Missing + public var nsfw: Boolean? by ::_nsfw.delegate() + + private var _parentId: OptionalSnowflake? = OptionalSnowflake.Missing + public var parentId: Snowflake? by ::_parentId.delegate() + + private var _rateLimitPerUser: Optional = Optional.Missing() + public var rateLimitPerUser: Duration? by ::_rateLimitPerUser.delegate() + + private var _permissionOverwrites: Optional?> = Optional.Missing() + override var permissionOverwrites: MutableSet? by ::_permissionOverwrites.delegate() + + private var _defaultAutoArchiveDuration: Optional = Optional.Missing() + + /** + * The default [duration][ArchiveDuration] that the clients use (not the API) for newly created threads in the + * channel, to automatically archive the thread after recent activity. + */ + public var defaultAutoArchiveDuration: ArchiveDuration? by ::_defaultAutoArchiveDuration.delegate() + + private var _flags: Optional = Optional.Missing() + public var flags: ChannelFlags? by ::_flags.delegate() + + private var _defaultReactionEmoji: Optional = Optional.Missing() + public var defaultReactionEmoji: DefaultReaction? by ::_defaultReactionEmoji.delegate() + public var defaultReactionEmojiId: Snowflake? = null + public var defaultReactionEmojiName: String? = null + + private var _availableTags: Optional> = Optional.Missing() + public var availableTags: MutableList? by ::_availableTags.delegate() + + public fun tag(name: String, builder: ForumTagBuilder.() -> Unit = {}) { + contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } + val tag = ForumTagBuilder(name).apply(builder).toRequest() + availableTags?.add(tag) ?: run { availableTags = mutableListOf(tag) } + } + + private var _defaultThreadRateLimitPerUser: Optional = Optional.Missing() + public var defaultThreadRateLimitPerUser: Duration? by ::_defaultThreadRateLimitPerUser.delegate() + + private var _defaultSortOrder: Optional = Optional.Missing() + public var defaultSortOrder: SortOrderType? by ::_defaultSortOrder.delegate() + + override fun toRequest(): ChannelModifyPatchRequest = ChannelModifyPatchRequest( + name = _name, + position = _position, + topic = _topic, + nsfw = _nsfw, + rateLimitPerUser = _rateLimitPerUser, + permissionOverwrites = _permissionOverwrites, + parentId = _parentId, + defaultAutoArchiveDuration = _defaultAutoArchiveDuration, + defaultReactionEmoji = when { + defaultReactionEmojiId != null || defaultReactionEmojiName != null -> + DefaultReaction( + emojiId = defaultReactionEmojiId, + emojiName = defaultReactionEmojiName, + ).optional() + else -> _defaultReactionEmoji + }, + defaultThreadRateLimitPerUser = _defaultThreadRateLimitPerUser, + availableTags = _availableTags, + defaultSortOrder = _defaultSortOrder, + flags = _flags + ) +} + @KordDsl public class VoiceChannelModifyBuilder : PermissionOverwritesModifyBuilder, AuditRequestBuilder { diff --git a/rest/src/commonMain/kotlin/builder/channel/MediaChannelCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/MediaChannelCreateBuilder.kt new file mode 100644 index 000000000000..1e64fbedcf17 --- /dev/null +++ b/rest/src/commonMain/kotlin/builder/channel/MediaChannelCreateBuilder.kt @@ -0,0 +1,94 @@ +package dev.kord.rest.builder.channel + +import dev.kord.common.annotation.KordDsl +import dev.kord.common.entity.* +import dev.kord.common.entity.optional.* +import dev.kord.common.entity.optional.delegate.delegate +import dev.kord.rest.builder.AuditRequestBuilder +import dev.kord.rest.json.request.ForumTagRequest +import dev.kord.rest.json.request.GuildChannelCreateRequest +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract +import kotlin.time.Duration + +@KordDsl +public class MediaChannelCreateBuilder(public var name: String) : + PermissionOverwritesCreateBuilder, + AuditRequestBuilder { + override var reason: String? = null + + private var _topic: Optional = Optional.Missing() + public var topic: String? by ::_topic.delegate() + + private var _rateLimitPerUser: Optional = Optional.Missing() + public var rateLimitPerUser: Duration? by ::_rateLimitPerUser.delegate() + + private var _position: OptionalInt = OptionalInt.Missing + public var position: Int? by ::_position.delegate() + + private var _parentId: OptionalSnowflake = OptionalSnowflake.Missing + public var parentId: Snowflake? by ::_parentId.delegate() + + private var _nsfw: OptionalBoolean = OptionalBoolean.Missing + public var nsfw: Boolean? by ::_nsfw.delegate() + + private var _defaultAutoArchiveDuration: Optional = Optional.Missing() + + /** + * The default [duration][ArchiveDuration] that the clients use (not the API) for newly created threads in the + * channel, to automatically archive the thread after recent activity. + */ + public var defaultAutoArchiveDuration: ArchiveDuration? by ::_defaultAutoArchiveDuration.delegate() + + override var permissionOverwrites: MutableSet = mutableSetOf() + + private var _defaultReactionEmoji: Optional = Optional.Missing() + public var defaultReactionEmoji: DefaultReaction? by ::_defaultReactionEmoji.delegate() + public var defaultReactionEmojiId: Snowflake? = null + public var defaultReactionEmojiName: String? = null + + private var _availableTags: Optional?> = Optional.Missing() + public var availableTags: MutableList? by ::_availableTags.delegate() + + public fun tag(name: String, builder: ForumTagBuilder.() -> Unit = {}) { + contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } + + if (availableTags == null) availableTags = mutableListOf() + + val tagBuilder = ForumTagBuilder(name).apply(builder) + availableTags?.add(tagBuilder.toRequest()) + } + + private var _defaultThreadRateLimitPerUser: Optional = Optional.Missing() + public var defaultThreadRateLimitPerUser: Duration? by ::_defaultThreadRateLimitPerUser.delegate() + + private var _defaultSortOrder: Optional = Optional.Missing() + public var defaultSortOrder: SortOrderType? by ::_defaultSortOrder.delegate() + + private var _flags: Optional = Optional.Missing() + public var flags: ChannelFlags? by ::_flags.delegate() + + override fun toRequest(): GuildChannelCreateRequest = GuildChannelCreateRequest( + name = name, + type = ChannelType.GuildForum, + topic = _topic, + rateLimitPerUser = _rateLimitPerUser, + position = _position, + parentId = _parentId, + nsfw = _nsfw, + permissionOverwrite = Optional.missingOnEmpty(permissionOverwrites), + defaultAutoArchiveDuration = _defaultAutoArchiveDuration, + defaultReactionEmoji = when { + defaultReactionEmojiId != null || defaultReactionEmojiName != null -> + DefaultReaction( + emojiId = defaultReactionEmojiId, + emojiName = defaultReactionEmojiName, + ).optional() + else -> _defaultReactionEmoji + }, + defaultThreadRateLimitPerUser = _defaultThreadRateLimitPerUser, + availableTags = _availableTags, + defaultSortOrder = _defaultSortOrder, + flags = _flags, + ) +} diff --git a/rest/src/commonMain/kotlin/builder/guild/GuildCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/guild/GuildCreateBuilder.kt index 05add6c69c77..73724da7bd99 100644 --- a/rest/src/commonMain/kotlin/builder/guild/GuildCreateBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/guild/GuildCreateBuilder.kt @@ -11,9 +11,7 @@ import dev.kord.common.entity.optional.delegate.delegate import dev.kord.common.entity.optional.map import dev.kord.rest.Image import dev.kord.rest.builder.RequestBuilder -import dev.kord.rest.builder.channel.CategoryCreateBuilder -import dev.kord.rest.builder.channel.NewsChannelCreateBuilder -import dev.kord.rest.builder.channel.TextChannelCreateBuilder +import dev.kord.rest.builder.channel.* import dev.kord.rest.builder.role.RoleCreateBuilder import dev.kord.rest.json.request.GuildChannelCreateRequest import dev.kord.rest.json.request.GuildCreateRequest @@ -116,10 +114,20 @@ public class GuildCreateBuilder(public var name: String) : RequestBuilder Unit + builder: ForumChannelCreateBuilder.() -> Unit, + ): Snowflake { + contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } + channels.add(ForumChannelCreateBuilder(name).apply(builder).toRequest().copy(id = OptionalSnowflake.Value(id))) + return id + } + + public inline fun mediaChannel( + name: String, + id: Snowflake = newUniqueSnowflake(), + builder: MediaChannelCreateBuilder.() -> Unit, ): Snowflake { contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } - channels.add(TextChannelCreateBuilder(name).apply(builder).toRequest().copy(id=OptionalSnowflake.Value(id))) + channels.add(MediaChannelCreateBuilder(name).apply(builder).toRequest().copy(id = OptionalSnowflake.Value(id))) return id } diff --git a/rest/src/commonMain/kotlin/builder/message/create/WebhookMessageCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/WebhookMessageCreateBuilder.kt index cbaeacf9b0ee..9cce3823106a 100644 --- a/rest/src/commonMain/kotlin/builder/message/create/WebhookMessageCreateBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/create/WebhookMessageCreateBuilder.kt @@ -2,6 +2,7 @@ package dev.kord.rest.builder.message.create import dev.kord.common.annotation.KordDsl import dev.kord.common.entity.ChannelType.GuildForum +import dev.kord.common.entity.ChannelType.GuildMedia import dev.kord.common.entity.MessageFlags import dev.kord.common.entity.optional.* import dev.kord.common.entity.optional.delegate.delegate @@ -44,7 +45,7 @@ public class WebhookMessageCreateBuilder : private var _threadName: Optional = Optional.Missing() - /** Name of the thread to create (requires the webhook channel to be a [GuildForum] channel). */ + /** Name of the thread to create (requires the webhook channel to be a [GuildForum] or [GuildMedia] channel). */ public var threadName: String? by ::_threadName.delegate() override fun toRequest(): MultiPartWebhookExecuteRequest { diff --git a/rest/src/commonMain/kotlin/service/ChannelService.kt b/rest/src/commonMain/kotlin/service/ChannelService.kt index fe8e30b3240a..81adedd034af 100644 --- a/rest/src/commonMain/kotlin/service/ChannelService.kt +++ b/rest/src/commonMain/kotlin/service/ChannelService.kt @@ -444,6 +444,15 @@ public suspend inline fun ChannelService.patchForumChannel( return patchChannel(channelId, modifyBuilder.toRequest(), modifyBuilder.reason) } +public suspend inline fun ChannelService.patchMediaChannel( + channelId: Snowflake, + builder: MediaChannelModifyBuilder.() -> Unit, +): DiscordChannel { + contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } + val modifyBuilder = MediaChannelModifyBuilder().apply(builder) + return patchChannel(channelId, modifyBuilder.toRequest(), modifyBuilder.reason) +} + public suspend inline fun ChannelService.patchVoiceChannel( channelId: Snowflake, builder: VoiceChannelModifyBuilder.() -> Unit diff --git a/rest/src/commonMain/kotlin/service/GuildService.kt b/rest/src/commonMain/kotlin/service/GuildService.kt index f2f849adeffd..35a3510b805c 100644 --- a/rest/src/commonMain/kotlin/service/GuildService.kt +++ b/rest/src/commonMain/kotlin/service/GuildService.kt @@ -554,6 +554,17 @@ public suspend inline fun GuildService.createForumChannel( val createBuilder = ForumChannelCreateBuilder(name).apply(builder) return createGuildChannel(guildId, createBuilder.toRequest(), createBuilder.reason) } + +public suspend inline fun GuildService.createMediaChannel( + guildId: Snowflake, + name: String, + builder: MediaChannelCreateBuilder.() -> Unit, +): DiscordChannel { + contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } + val createBuilder = MediaChannelCreateBuilder(name).apply(builder) + return createGuildChannel(guildId, createBuilder.toRequest(), createBuilder.reason) +} + public suspend inline fun GuildService.createNewsChannel( guildId: Snowflake, name: String,