Skip to content

Commit

Permalink
Implement forums (#684)
Browse files Browse the repository at this point in the history
* add forum error codes

* update docs of Permission.SendMessages for forums

* add ChannelType.GuildForum

* add ChannelFlags

* add DiscordChannel.flags

* add ChannelData.flags

* add Channel.flags

* add cache updates for lastMessageId of forum channels

* Implmenet high level abstractions

* Error 220003

* API dump

* Fix compile error

* More error codes

* Add `ChannelFlag.RequireTag`

* Add `thread_name` for execute webhook

* Regenerate `ChannelType`

* Remove `nsfwLevel` from channel

* Dump API

* Add SortOrderType

* Add missing fields to DiscordChannel

* Imports

* Add missing properties for channel builders (#712)

* Add missing properties for create forum channel

* api dump

* add missing fields in the other builders

* api dump

* move flags to forum threads

* apply suggestions

* Small fixes

Co-authored-by: Lukellmann <lukellmann@gmail.com>

* TextChannelModifyBuilder.defaultThreadRateLimitPerUser

* Update KDoc for ChannelType.PublicGuildThread

see discord/discord-api-docs#5556

* Add ChannelData.defaultSortOrder (#727)

* Add default forum layout (#749)

* Fix nullability and docs

* Add missing default layout to core type (#752)

* Message counts and position for channel and message (#726)

* Message counts and position for channel and message

* Api Dump

* Is this dump better?

* Update caches for message count and total message sent

* Fix merge

* Forum posts (#709)

* support for creating forum posts

* api dump

* support for uploading files on forum posts

* more support to forums and forum threads

* fix errors

* maintain code consistency

* add forum tag routes

* Api Dump

* Update Intent KDoc

* Check for applied tags

* Remove ForumChannelThread type

* Move possible functions to ForumChannelBehavior

* add applied tags to modify builder

* Properly configure JVM auto-provisioning

* Fix appliedTags mutability

* Fix spacings

* Final fixes

---------

Co-authored-by: Luis <40919071+dookon@users.noreply.github.com>
Co-authored-by: Lukellmann <lukellmann@gmail.com>
Co-authored-by: hope <truehope9000@gmail.com>
Co-authored-by: Michael Rittmeister <michael@rittmeister.in>

---------

Co-authored-by: Lukellmann <lukellmann@gmail.com>
Co-authored-by: Lukellmann <47486203+Lukellmann@users.noreply.github.com>
Co-authored-by: Luis <40919071+dookon@users.noreply.github.com>
Co-authored-by: NoComment <67918617+NoComment1105@users.noreply.github.com>
Co-authored-by: Michael Rittmeister <michael@rittmeister.in>
Co-authored-by: Luis <luisflima.bg@gmail.com>
  • Loading branch information
7 people authored Mar 20, 2023
1 parent 6c14449 commit b976bf0
Show file tree
Hide file tree
Showing 50 changed files with 2,331 additions and 292 deletions.
232 changes: 217 additions & 15 deletions common/api/common.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public sealed class ChannelType(
public object PublicNewsThread : ChannelType(10)

/**
* A temporary sub-channel within a [GuildText] channel.
* A temporary sub-channel within a [GuildText] or [GuildForum] channel.
*/
public object PublicGuildThread : ChannelType(11)

Expand All @@ -109,6 +109,11 @@ public sealed class ChannelType(
*/
public object GuildDirectory : ChannelType(14)

/**
* A channel that can only contain threads.
*/
public object GuildForum : ChannelType(15)

internal object Serializer : KSerializer<ChannelType> {
public override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor("dev.kord.common.entity.ChannelType", PrimitiveKind.INT)
Expand All @@ -128,6 +133,7 @@ public sealed class ChannelType(
12 -> PrivateThread
13 -> GuildStageVoice
14 -> GuildDirectory
15 -> GuildForum
else -> Unknown(value)
}
}
Expand All @@ -149,6 +155,7 @@ public sealed class ChannelType(
PrivateThread,
GuildStageVoice,
GuildDirectory,
GuildForum,
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT!
@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting",
"ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection"))

package dev.kord.common.entity

import kotlin.Any
import kotlin.Boolean
import kotlin.Int
import kotlin.LazyThreadSafetyMode.PUBLICATION
import kotlin.String
import kotlin.Suppress
import kotlin.collections.List
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder

/**
* See [ForumLayoutType]s in the
* [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#channel-object-forum-layout-types).
*/
@Serializable(with = ForumLayoutType.Serializer::class)
public sealed class ForumLayoutType(
/**
* The raw value used by Discord.
*/
public val `value`: Int,
) {
public final override fun equals(other: Any?): Boolean = this === other ||
(other is ForumLayoutType && this.value == other.value)

public final override fun hashCode(): Int = value.hashCode()

public final override fun toString(): String =
"ForumLayoutType.${this::class.simpleName}(value=$value)"

/**
* An unknown [ForumLayoutType].
*
* This is used as a fallback for [ForumLayoutType]s that haven't been added to Kord yet.
*/
public class Unknown(
`value`: Int,
) : ForumLayoutType(value)

/**
* No default has been set for forum channel.
*/
public object NotSet : ForumLayoutType(0)

/**
* Display posts as a list.
*/
public object ListView : ForumLayoutType(1)

/**
* Display posts as a collection of tiles.
*/
public object GalleryView : ForumLayoutType(2)

internal object Serializer : KSerializer<ForumLayoutType> {
public override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor("dev.kord.common.entity.ForumLayoutType",
PrimitiveKind.INT)

public override fun serialize(encoder: Encoder, `value`: ForumLayoutType) =
encoder.encodeInt(value.value)

public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) {
0 -> NotSet
1 -> ListView
2 -> GalleryView
else -> Unknown(value)
}
}

public companion object {
/**
* A [List] of all known [ForumLayoutType]s.
*/
public val entries: List<ForumLayoutType> by lazy(mode = PUBLICATION) {
listOf(
NotSet,
ListView,
GalleryView,
)
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT!
@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting",
"ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection"))

package dev.kord.common.entity

import kotlin.Any
import kotlin.Boolean
import kotlin.Int
import kotlin.LazyThreadSafetyMode.PUBLICATION
import kotlin.String
import kotlin.Suppress
import kotlin.collections.List
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder

/**
* See [SortOrderType]s in the
* [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#channel-object-sort-order-types).
*/
@Serializable(with = SortOrderType.Serializer::class)
public sealed class SortOrderType(
/**
* The raw value used by Discord.
*/
public val `value`: Int,
) {
public final override fun equals(other: Any?): Boolean = this === other ||
(other is SortOrderType && this.value == other.value)

public final override fun hashCode(): Int = value.hashCode()

public final override fun toString(): String =
"SortOrderType.${this::class.simpleName}(value=$value)"

/**
* An unknown [SortOrderType].
*
* This is used as a fallback for [SortOrderType]s that haven't been added to Kord yet.
*/
public class Unknown(
`value`: Int,
) : SortOrderType(value)

/**
* Sort forum posts by activity.
*/
public object LatestActivity : SortOrderType(0)

/**
* Sort forum posts by creation time (from most recent to oldest).
*/
public object CreationDate : SortOrderType(1)

internal object Serializer : KSerializer<SortOrderType> {
public override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor("dev.kord.common.entity.SortOrderType", PrimitiveKind.INT)

public override fun serialize(encoder: Encoder, `value`: SortOrderType) =
encoder.encodeInt(value.value)

public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) {
0 -> LatestActivity
1 -> CreationDate
else -> Unknown(value)
}
}

public companion object {
/**
* A [List] of all known [SortOrderType]s.
*/
public val entries: List<SortOrderType> by lazy(mode = PUBLICATION) {
listOf(
LatestActivity,
CreationDate,
)
}

}
}
Loading

0 comments on commit b976bf0

Please sign in to comment.