Skip to content

Commit 4aa9701

Browse files
authored
Add MediaChannels (#853)
Common functionality between ForumChannel and MediaChannel was extracted to a new ThreadOnlyChannel supertype. See discord/discord-api-docs#6232
1 parent 027c237 commit 4aa9701

File tree

30 files changed

+876
-113
lines changed

30 files changed

+876
-113
lines changed

common/api/common.api

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,10 @@ public final class dev/kord/common/entity/ChannelFlag$Companion {
17111711
public fun values ()[Ldev/kord/common/entity/ChannelFlag;
17121712
}
17131713

1714+
public final class dev/kord/common/entity/ChannelFlag$HideMediaDownloadOptions : dev/kord/common/entity/ChannelFlag {
1715+
public static final field INSTANCE Ldev/kord/common/entity/ChannelFlag$HideMediaDownloadOptions;
1716+
}
1717+
17141718
public final class dev/kord/common/entity/ChannelFlag$Pinned : dev/kord/common/entity/ChannelFlag {
17151719
public static final field INSTANCE Ldev/kord/common/entity/ChannelFlag$Pinned;
17161720
}
@@ -1801,6 +1805,10 @@ public final class dev/kord/common/entity/ChannelType$GuildForum : dev/kord/comm
18011805
public static final field INSTANCE Ldev/kord/common/entity/ChannelType$GuildForum;
18021806
}
18031807

1808+
public final class dev/kord/common/entity/ChannelType$GuildMedia : dev/kord/common/entity/ChannelType {
1809+
public static final field INSTANCE Ldev/kord/common/entity/ChannelType$GuildMedia;
1810+
}
1811+
18041812
public final class dev/kord/common/entity/ChannelType$GuildNews : dev/kord/common/entity/ChannelType {
18051813
public static final field INSTANCE Ldev/kord/common/entity/ChannelType$GuildNews;
18061814
}

common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelFlag.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public sealed class ChannelFlag(
8080
public fun ordinal(): Int = when (this) {
8181
Pinned -> 0
8282
RequireTag -> 1
83+
HideMediaDownloadOptions -> 2
8384
is Unknown -> Int.MAX_VALUE
8485
}
8586

@@ -103,16 +104,23 @@ public sealed class ChannelFlag(
103104
) : ChannelFlag(shift)
104105

105106
/**
106-
* This thread is pinned to the top of its parent [GuildForum][ChannelType.GuildForum] channel.
107+
* This thread is pinned to the top of its parent [GuildForum][ChannelType.GuildForum] or
108+
* [GuildMedia][ChannelType.GuildMedia] channel.
107109
*/
108110
public object Pinned : ChannelFlag(1)
109111

110112
/**
111113
* Whether a tag is required to be specified when creating a thread in a
112-
* [GuildForum][ChannelType.GuildForum] channel.
114+
* [GuildForum][ChannelType.GuildForum] or [GuildMedia][ChannelType.GuildMedia] channel.
113115
*/
114116
public object RequireTag : ChannelFlag(4)
115117

118+
/**
119+
* When set hides the embedded media download options. Available only for
120+
* [GuildMedia][ChannelType.GuildMedia] channels.
121+
*/
122+
public object HideMediaDownloadOptions : ChannelFlag(15)
123+
116124
public companion object {
117125
/**
118126
* A [List] of all known [ChannelFlag]s.
@@ -121,6 +129,7 @@ public sealed class ChannelFlag(
121129
listOf(
122130
Pinned,
123131
RequireTag,
132+
HideMediaDownloadOptions,
124133
)
125134
}
126135

@@ -148,6 +157,7 @@ public sealed class ChannelFlag(
148157
public fun fromShift(shift: Int): ChannelFlag = when (shift) {
149158
1 -> Pinned
150159
4 -> RequireTag
160+
15 -> HideMediaDownloadOptions
151161
else -> Unknown(shift)
152162
}
153163

@@ -161,6 +171,7 @@ public sealed class ChannelFlag(
161171
public open fun valueOf(name: String): ChannelFlag = when (name) {
162172
"Pinned" -> Pinned
163173
"RequireTag" -> RequireTag
174+
"HideMediaDownloadOptions" -> HideMediaDownloadOptions
164175
else -> throw IllegalArgumentException(name)
165176
}
166177

common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelType.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ public sealed class ChannelType(
117117
*/
118118
public object GuildForum : ChannelType(15)
119119

120+
/**
121+
* A channel that can only contain threads, similar to [GuildForum] channels.
122+
*/
123+
public object GuildMedia : ChannelType(16)
124+
120125
internal object Serializer : KSerializer<ChannelType> {
121126
override val descriptor: SerialDescriptor =
122127
PrimitiveSerialDescriptor("dev.kord.common.entity.ChannelType", PrimitiveKind.INT)
@@ -146,6 +151,7 @@ public sealed class ChannelType(
146151
GuildStageVoice,
147152
GuildDirectory,
148153
GuildForum,
154+
GuildMedia,
149155
)
150156
}
151157

@@ -167,6 +173,7 @@ public sealed class ChannelType(
167173
13 -> GuildStageVoice
168174
14 -> GuildDirectory
169175
15 -> GuildForum
176+
16 -> GuildMedia
170177
else -> Unknown(value, null)
171178
}
172179
}

common/src/commonMain/kotlin/entity/DiscordChannel.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
"Student-Hubs-FAQ) containing the listed servers.",
3838
),
3939
Entry("GuildForum", intValue = 15, kDoc = "A channel that can only contain threads."),
40+
Entry(
41+
"GuildMedia", intValue = 16,
42+
kDoc = "A channel that can only contain threads, similar to [GuildForum] channels.",
43+
),
4044
],
4145
)
4246

@@ -47,12 +51,18 @@
4751
entries = [
4852
Entry(
4953
"Pinned", shift = 1,
50-
kDoc = "This thread is pinned to the top of its parent [GuildForum][ChannelType.GuildForum] channel.",
54+
kDoc = "This thread is pinned to the top of its parent [GuildForum][ChannelType.GuildForum] or " +
55+
"[GuildMedia][ChannelType.GuildMedia] channel.",
5156
),
5257
Entry(
5358
"RequireTag", shift = 4,
5459
kDoc = "Whether a tag is required to be specified when creating a thread in a " +
55-
"[GuildForum][ChannelType.GuildForum] channel.",
60+
"[GuildForum][ChannelType.GuildForum] or [GuildMedia][ChannelType.GuildMedia] channel.",
61+
),
62+
Entry(
63+
"HideMediaDownloadOptions", shift = 15, noStaticFieldIfEntityWasEnum = true,
64+
kDoc = "When set hides the embedded media download options. Available only for " +
65+
"[GuildMedia][ChannelType.GuildMedia] channels.",
5666
),
5767
],
5868
)

0 commit comments

Comments
 (0)