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

Feature: Threads #349

Merged
merged 55 commits into from
Jul 28, 2021
Merged

Feature: Threads #349

merged 55 commits into from
Jul 28, 2021

Conversation

HopeBaron
Copy link
Member

This adds thread support to Kord:

  • Added a PrivateThreadParent/ThreadParent behaviors to abstract the new functionalities related to channels that can own another channel.
    Note: Maybe we should rename those to PrivateThreadOwner and ThreadOwner respectively.

  • Added support to threads new endpoints / events.

  • Switched to version 9 for both rest and gateway.

core/src/main/kotlin/cache/data/ChannelData.kt Outdated Show resolved Hide resolved
rest/src/main/kotlin/json/request/ChannelRequests.kt Outdated Show resolved Hide resolved
rest/src/main/kotlin/json/request/ChannelRequests.kt Outdated Show resolved Hide resolved
rest/src/main/kotlin/json/request/ChannelRequests.kt Outdated Show resolved Hide resolved
rest/src/main/kotlin/json/request/ThreadRequests.kt Outdated Show resolved Hide resolved
rest/src/main/kotlin/route/Route.kt Outdated Show resolved Hide resolved
Copy link
Contributor

@BartArys BartArys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still quite a large amount of new API that needs documenting in core

core/src/main/kotlin/behavior/ThreadUserBehavior.kt Outdated Show resolved Hide resolved
Comment on lines +193 to +194
object ThreeDays : ArchiveDuration(4320)
object Week : ArchiveDuration(10080)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if there's an official documentation out there, but these values are limited to a certain guild boost level, which should be documented.

core/src/main/kotlin/Util.kt Show resolved Hide resolved
@@ -492,6 +494,44 @@ class RestServiceTest {
updated.delete()
}

@Order(28)
@Test
@Disabled("Requires Community Guild")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect. Discord is rolling threads out for all guilds (eventually). These tests should eventually be enabled.

Comment on lines 85 to 96
internal suspend fun ThreadParentChannelBehavior.startThread(
name: String,
archiveDuration: ArchiveDuration,
type: ChannelType
): ThreadChannel {

val response =
kord.rest.channel.startPrivateThread(id, StartThreadRequest(name, archiveDuration, Optional.Value(type)))
val data = ChannelData.from(response)

return Channel.from(data, kord) as ThreadChannel
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this? and Is itsupposed to be internal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the function abstracts the logic behind starting a thread, but it's not safe to use by the outer-world

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, alright. This should be documented and the name should indicate that this starts a thread without a message

Comment on lines 244 to 265
suspend fun startPublicThread(
channelId: Snowflake,
messageId: Snowflake,
request: StartThreadRequest
): DiscordChannel {
return call(Route.StartPublicThreadPost) {
keys[Route.ChannelId] = channelId
keys[Route.MessageId] = messageId
body(StartThreadRequest.serializer(), request)
}
}


suspend fun startPrivateThread(
channelId: Snowflake,
request: StartThreadRequest
): DiscordChannel {
return call(Route.StartPrivateThreadPost) {
keys[Route.ChannelId] = channelId
body(StartThreadRequest.serializer(), request)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions are incorrectly named, they don't create public and private threads respectively.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

Comment on lines 85 to 96
internal suspend fun ThreadParentChannelBehavior.startThread(
name: String,
archiveDuration: ArchiveDuration,
type: ChannelType
): ThreadChannel {

val response =
kord.rest.channel.startPrivateThread(id, StartThreadRequest(name, archiveDuration, Optional.Value(type)))
val data = ChannelData.from(response)

return Channel.from(data, kord) as ThreadChannel
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, alright. This should be documented and the name should indicate that this starts a thread without a message

@HopeBaron HopeBaron merged commit f0d32be into 0.8.x Jul 28, 2021
@HopeBaron HopeBaron deleted the feature/0.8.x/threads branch October 7, 2021 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants