Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MediaChannels #853

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions common/api/common.api
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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.
Expand All @@ -121,6 +129,7 @@ public sealed class ChannelFlag(
listOf(
Pinned,
RequireTag,
HideMediaDownloadOptions,
)
}

Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChannelType> {
override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor("dev.kord.common.entity.ChannelType", PrimitiveKind.INT)
Expand Down Expand Up @@ -146,6 +151,7 @@ public sealed class ChannelType(
GuildStageVoice,
GuildDirectory,
GuildForum,
GuildMedia,
)
}

Expand All @@ -167,6 +173,7 @@ public sealed class ChannelType(
13 -> GuildStageVoice
14 -> GuildDirectory
15 -> GuildForum
16 -> GuildMedia
else -> Unknown(value, null)
}
}
Expand Down
14 changes: 12 additions & 2 deletions common/src/commonMain/kotlin/entity/DiscordChannel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
),
],
)

Expand All @@ -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.",
),
],
)
Expand Down
Loading