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 missing properties for channel builders #712

Merged
merged 7 commits into from
Nov 16, 2022
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
70 changes: 60 additions & 10 deletions rest/api/rest.api

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions rest/src/main/kotlin/builder/channel/EditGuildChannelBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ package dev.kord.rest.builder.channel

import dev.kord.common.annotation.KordDsl
import dev.kord.common.entity.ArchiveDuration
import dev.kord.common.entity.ChannelFlags
import dev.kord.common.entity.DiscordDefaultReaction
import dev.kord.common.entity.DiscordForumTag
import dev.kord.common.entity.Overwrite
import dev.kord.common.entity.Snowflake
import dev.kord.common.entity.SortOrderType
import dev.kord.common.entity.VideoQualityMode
import dev.kord.common.entity.optional.Optional
import dev.kord.common.entity.optional.OptionalBoolean
import dev.kord.common.entity.optional.OptionalInt
import dev.kord.common.entity.optional.OptionalSnowflake
import dev.kord.common.entity.optional.delegate.delegate
import dev.kord.common.entity.optional.optional
import dev.kord.rest.builder.AuditRequestBuilder
import dev.kord.rest.json.request.ChannelModifyPatchRequest
import kotlin.DeprecationLevel.HIDDEN
Expand Down Expand Up @@ -96,6 +101,23 @@ public class ForumChannelModifyBuilder : PermissionOverwritesModifyBuilder,
*/
public var defaultAutoArchiveDuration: ArchiveDuration? by ::_defaultAutoArchiveDuration.delegate()

private var _flags: Optional<ChannelFlags> = Optional.Missing()
public var flags: ChannelFlags? by ::_flags.delegate()

private var _defaultReactionEmoji: Optional<DiscordDefaultReaction?> = Optional.Missing()
public var defaultReactionEmoji: DiscordDefaultReaction? by ::_defaultReactionEmoji.delegate()
public var defaultReactionEmojiId: Snowflake? = null
public var defaultReactionEmojiName: String? = null

private var _availableTags: Optional<List<DiscordForumTag>> = Optional.Missing()
public var availableTags: List<DiscordForumTag>? by ::_availableTags.delegate()

private var _defaultThreadRateLimitPerUser: Optional<Duration> = Optional.Missing()
public var defaultThreadRateLimitPerUser: Duration? by ::_defaultThreadRateLimitPerUser.delegate()

private var _defaultSortOrder: Optional<SortOrderType?> = Optional.Missing()
public var defaultSortOrder: SortOrderType? by ::_defaultSortOrder.delegate()

override fun toRequest(): ChannelModifyPatchRequest = ChannelModifyPatchRequest(
name = _name,
position = _position,
Expand All @@ -105,6 +127,18 @@ public class ForumChannelModifyBuilder : PermissionOverwritesModifyBuilder,
permissionOverwrites = _permissionOverwrites,
parentId = _parentId,
defaultAutoArchiveDuration = _defaultAutoArchiveDuration,
defaultReactionEmoji = when {
defaultReactionEmojiId != null || defaultReactionEmojiName != null ->
DiscordDefaultReaction(
emojiId = defaultReactionEmojiId,
emojiName = defaultReactionEmojiName,
).optional()
else -> _defaultReactionEmoji
},
defaultThreadRateLimitPerUser = _defaultThreadRateLimitPerUser,
availableTags = _availableTags,
defaultSortOrder = _defaultSortOrder,
flags = _flags
)

}
Expand Down
29 changes: 29 additions & 0 deletions rest/src/main/kotlin/builder/channel/ForumChannelCreateBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ package dev.kord.rest.builder.channel
import dev.kord.common.annotation.KordDsl
import dev.kord.common.entity.ArchiveDuration
import dev.kord.common.entity.ChannelType
import dev.kord.common.entity.DiscordDefaultReaction
import dev.kord.common.entity.DiscordForumTag
import dev.kord.common.entity.Overwrite
import dev.kord.common.entity.Snowflake
import dev.kord.common.entity.SortOrderType
import dev.kord.common.entity.optional.Optional
import dev.kord.common.entity.optional.OptionalBoolean
import dev.kord.common.entity.optional.OptionalInt
import dev.kord.common.entity.optional.OptionalSnowflake
import dev.kord.common.entity.optional.delegate.delegate
import dev.kord.common.entity.optional.optional
import dev.kord.rest.builder.AuditRequestBuilder
import dev.kord.rest.json.request.GuildChannelCreateRequest
import kotlin.time.Duration
Expand Down Expand Up @@ -45,6 +49,20 @@ public class ForumChannelCreateBuilder(public var name: String) :

override var permissionOverwrites: MutableSet<Overwrite> = mutableSetOf()

private var _defaultReactionEmoji: Optional<DiscordDefaultReaction?> = Optional.Missing()
public var defaultReactionEmoji: DiscordDefaultReaction? by ::_defaultReactionEmoji.delegate()
public var defaultReactionEmojiId: Snowflake? = null
public var defaultReactionEmojiName: String? = null

private var _availableTags: Optional<List<DiscordForumTag>?> = Optional.Missing()
public var availableTags: List<DiscordForumTag>? by ::_availableTags.delegate()

private var _defaultThreadRateLimitPerUser: Optional<Duration> = Optional.Missing()
public var defaultThreadRateLimitPerUser: Duration? by ::_defaultThreadRateLimitPerUser.delegate()

private var _defaultSortOrder: Optional<SortOrderType?> = Optional.Missing()
public var defaultSortOrder: SortOrderType? by ::_defaultSortOrder.delegate()

override fun toRequest(): GuildChannelCreateRequest = GuildChannelCreateRequest(
name = name,
type = ChannelType.GuildForum,
Expand All @@ -55,5 +73,16 @@ public class ForumChannelCreateBuilder(public var name: String) :
nsfw = _nsfw,
permissionOverwrite = Optional.missingOnEmpty(permissionOverwrites),
defaultAutoArchiveDuration = _defaultAutoArchiveDuration,
defaultReactionEmoji = when {
defaultReactionEmojiId != null || defaultReactionEmojiName != null ->
DiscordDefaultReaction(
emojiId = defaultReactionEmojiId,
emojiName = defaultReactionEmojiName,
).optional()
else -> _defaultReactionEmoji
},
defaultThreadRateLimitPerUser = _defaultThreadRateLimitPerUser,
availableTags = _availableTags,
defaultSortOrder = _defaultSortOrder,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class TextChannelCreateBuilder(public var name: String) :

override var permissionOverwrites: MutableSet<Overwrite> = mutableSetOf()

private var _defaultThreadRateLimitPerUser: Optional<Duration> = Optional.Missing()
public var defaultThreadRateLimitPerUser: Duration? by ::_defaultThreadRateLimitPerUser.delegate()

override fun toRequest(): GuildChannelCreateRequest = GuildChannelCreateRequest(
name = name,
type = ChannelType.GuildText,
Expand All @@ -55,5 +58,6 @@ public class TextChannelCreateBuilder(public var name: String) :
nsfw = _nsfw,
permissionOverwrite = Optional.missingOnEmpty(permissionOverwrites),
defaultAutoArchiveDuration = _defaultAutoArchiveDuration,
defaultThreadRateLimitPerUser = _defaultThreadRateLimitPerUser
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.kord.rest.builder.channel.thread

import dev.kord.common.entity.ArchiveDuration
import dev.kord.common.entity.ChannelFlags
import dev.kord.common.entity.optional.Optional
import dev.kord.common.entity.optional.OptionalBoolean
import dev.kord.common.entity.optional.delegate.delegate
Expand Down Expand Up @@ -28,14 +29,18 @@ public class ThreadModifyBuilder : AuditRequestBuilder<ChannelModifyPatchRequest
private var _invitable: OptionalBoolean = OptionalBoolean.Missing
public var invitable: Boolean? by ::_invitable.delegate()

private var _flags: Optional<ChannelFlags> = Optional.Missing()
public var flags: ChannelFlags? by ::_flags.delegate()

override fun toRequest(): ChannelModifyPatchRequest {
return ChannelModifyPatchRequest(
name = _name,
locked = _locked,
archived = _archived,
autoArchiveDuration = _autoArchiveDuration,
rateLimitPerUser = _rateLimitPerUser,
invitable = _invitable
invitable = _invitable,
flags = _flags
)
}

Expand Down
9 changes: 9 additions & 0 deletions rest/src/main/kotlin/json/request/ChannelRequests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ public data class ChannelModifyPatchRequest(
val videoQualityMode: Optional<VideoQualityMode?> = Optional.Missing(),
@SerialName("default_auto_archive_duration")
val defaultAutoArchiveDuration: Optional<ArchiveDuration?> = Optional.Missing(),
@SerialName("default_reaction_emoji")
val defaultReactionEmoji: Optional<DiscordDefaultReaction?> = Optional.Missing(),
@SerialName("default_thread_rate_limit_per_user")
val defaultThreadRateLimitPerUser: Optional<DurationInSeconds> = Optional.Missing(),
val flags: Optional<ChannelFlags> = Optional.Missing(),
@SerialName("available_tags")
val availableTags: Optional<List<DiscordForumTag>> = Optional.Missing(),
@SerialName("default_sort_order")
val defaultSortOrder: Optional<SortOrderType?> = Optional.Missing(),
)

@Serializable
Expand Down
9 changes: 9 additions & 0 deletions rest/src/main/kotlin/json/request/GuildRequests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ public data class GuildChannelCreateRequest(
val id: OptionalSnowflake = OptionalSnowflake.Missing,
@SerialName("default_auto_archive_duration")
val defaultAutoArchiveDuration: Optional<ArchiveDuration> = Optional.Missing(),
@SerialName("default_reaction_emoji")
val defaultReactionEmoji: Optional<DiscordDefaultReaction?> = Optional.Missing(),
@SerialName("default_thread_rate_limit_per_user")
val defaultThreadRateLimitPerUser: Optional<DurationInSeconds> = Optional.Missing(),
val flags: Optional<ChannelFlags> = Optional.Missing(),
luisfbl marked this conversation as resolved.
Show resolved Hide resolved
@SerialName("available_tags")
val availableTags: Optional<List<DiscordForumTag>?> = Optional.Missing(),
@SerialName("default_sort_order")
val defaultSortOrder: Optional<SortOrderType?> = Optional.Missing(),
)

@Serializable
Expand Down