-
Notifications
You must be signed in to change notification settings - Fork 82
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
Feature: Threads #349
Conversation
There's still more modifications to do but hopefully we are close to a milestone in this regards.
core/src/main/kotlin/behavior/channel/threads/ThreadParentChannelBehavior.kt
Outdated
Show resolved
Hide resolved
core/src/main/kotlin/behavior/channel/threads/ThreadParentChannelBehavior.kt
Outdated
Show resolved
Hide resolved
core/src/main/kotlin/behavior/channel/threads/ThreadParentChannelBehavior.kt
Outdated
Show resolved
Hide resolved
core/src/main/kotlin/entity/channel/thread/NewsThreadChannel.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
object ThreeDays : ArchiveDuration(4320) | ||
object Week : ArchiveDuration(10080) |
There was a problem hiding this comment.
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.
@@ -492,6 +494,44 @@ class RestServiceTest { | |||
updated.delete() | |||
} | |||
|
|||
@Order(28) | |||
@Test | |||
@Disabled("Requires Community Guild") |
There was a problem hiding this comment.
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.
rest/src/main/kotlin/builder/channel/thread/ThreadModifyBuilder.kt
Outdated
Show resolved
Hide resolved
core/src/main/kotlin/behavior/channel/threads/ThreadChannelBehavior.kt
Outdated
Show resolved
Hide resolved
core/src/main/kotlin/behavior/channel/threads/ThreadParentChannelBehavior.kt
Show resolved
Hide resolved
core/src/main/kotlin/behavior/channel/threads/ThreadParentChannelBehavior.kt
Show resolved
Hide resolved
core/src/main/kotlin/behavior/channel/threads/ThreadParentChannelBehavior.kt
Show resolved
Hide resolved
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 | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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) | ||
} | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
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 | ||
} |
There was a problem hiding this comment.
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
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.