Skip to content

Commit

Permalink
Add fields to remaining builders
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Sep 17, 2024
1 parent 60548fc commit 58410a8
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public sealed class ApplicationIntegrationType(
/**
* App is installable to users
*/
public object UserInstall : ApplicationIntegrationType(0)
public object UserInstall : ApplicationIntegrationType(1)

internal object Serializer : KSerializer<ApplicationIntegrationType> {
override val descriptor: SerialDescriptor =
Expand All @@ -75,6 +75,7 @@ public sealed class ApplicationIntegrationType(
public val entries: List<ApplicationIntegrationType> by lazy(mode = PUBLICATION) {
listOf(
GuildInstall,
UserInstall,
)
}

Expand All @@ -84,6 +85,7 @@ public sealed class ApplicationIntegrationType(
*/
public fun from(`value`: Int): ApplicationIntegrationType = when (value) {
0 -> GuildInstall
1 -> UserInstall
else -> Unknown(value)
}
}
Expand Down
68 changes: 58 additions & 10 deletions rest/api/rest.api

Large diffs are not rendered by default.

51 changes: 45 additions & 6 deletions rest/api/rest.klib.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ public interface ApplicationCommandModifyBuilder : LocalizedNameModifyBuilder,
@Deprecated("'defaultPermission' is deprecated in favor of 'defaultMemberPermissions' and 'dmPermission'. Setting 'defaultPermission' to false can be replaced by setting 'defaultMemberPermissions' to empty Permissions and 'dmPermission' to false ('dmPermission' is only available for global commands).")
public var defaultPermission: Boolean?

public var integrationTypes: MutableList<ApplicationIntegrationType>?
public var contexts: MutableList<InteractionContextType>?

/** Indicates whether the command is age-restricted. */
public var nsfw: Boolean?

/**
* Requires this command to be executed in a specific [installation context][ApplicationIntegrationType].
*/
public fun requireIntegrationTypes(vararg types: ApplicationIntegrationType) {
integrationTypes?.addAll(types) ?: run { integrationTypes = types.toMutableList() }
}

/**
* Requires this command to be executed in a specific [interaction context][InteractionContextType].
*/
public fun requireContext(vararg types: InteractionContextType) {
contexts?.addAll(types) ?: run { contexts = types.toMutableList() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ internal class ChatInputCreateBuilderImpl(
state.defaultMemberPermissions,
state.dmPermission,
@Suppress("DEPRECATION") state.defaultPermission,
integrationTypes = state.integrationTypes,
contexts = state.contexts,
nsfw = state.nsfw,
)

Expand Down Expand Up @@ -203,7 +205,8 @@ internal class ChatInputModifyBuilderImpl : GlobalChatInputModifyBuilder {

@Deprecated("'defaultPermission' is deprecated in favor of 'defaultMemberPermissions' and 'dmPermission'. Setting 'defaultPermission' to false can be replaced by setting 'defaultMemberPermissions' to empty Permissions and 'dmPermission' to false ('dmPermission' is only available for global commands).")
override var defaultPermission: Boolean? by @Suppress("DEPRECATION") state::defaultPermission.delegate()

override var integrationTypes: MutableList<ApplicationIntegrationType>? by state::integrationTypes.delegate()
override var contexts: MutableList<InteractionContextType>? by state::contexts.delegate()
override var nsfw: Boolean? by state::nsfw.delegate()

override fun toRequest(): ApplicationCommandModifyRequest {
Expand All @@ -216,6 +219,8 @@ internal class ChatInputModifyBuilderImpl : GlobalChatInputModifyBuilder {
state.defaultMemberPermissions,
state.dmPermission,
@Suppress("DEPRECATION") state.defaultPermission,
integrationTypes = state.integrationTypes,
contexts = state.contexts,
nsfw = state.nsfw,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ internal class MessageCommandModifyBuilderImpl : GlobalMessageCommandModifyBuild

@Deprecated("'defaultPermission' is deprecated in favor of 'defaultMemberPermissions' and 'dmPermission'. Setting 'defaultPermission' to false can be replaced by setting 'defaultMemberPermissions' to empty Permissions and 'dmPermission' to false ('dmPermission' is only available for global commands).")
override var defaultPermission: Boolean? by @Suppress("DEPRECATION") state::defaultPermission.delegate()

override var integrationTypes: MutableList<ApplicationIntegrationType>? by state::integrationTypes.delegate()
override var contexts: MutableList<InteractionContextType>? by state::contexts.delegate()
override var nsfw: Boolean? by state::nsfw.delegate()

override fun toRequest(): ApplicationCommandModifyRequest {
Expand All @@ -41,6 +42,8 @@ internal class MessageCommandModifyBuilderImpl : GlobalMessageCommandModifyBuild
dmPermission = state.dmPermission,
defaultMemberPermissions = state.defaultMemberPermissions,
defaultPermission = @Suppress("DEPRECATION") state.defaultPermission,
integrationTypes = state.integrationTypes,
contexts = state.contexts,
nsfw = state.nsfw,
)

Expand Down Expand Up @@ -83,6 +86,8 @@ internal class MessageCommandCreateBuilderImpl(override var name: String) : Glob
dmPermission = state.dmPermission,
defaultMemberPermissions = state.defaultMemberPermissions,
defaultPermission = @Suppress("DEPRECATION") state.defaultPermission,
integrationTypes = state.integrationTypes,
contexts = state.contexts,
nsfw = state.nsfw,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ internal class UserCommandModifyBuilderImpl : GlobalUserCommandModifyBuilder {
override var defaultMemberPermissions: Permissions? by state::defaultMemberPermissions.delegate()
@Suppress("OVERRIDE_DEPRECATION")
override var dmPermission: Boolean? by state::dmPermission.delegate()

override var integrationTypes: MutableList<ApplicationIntegrationType>? by state::integrationTypes.delegate()
override var contexts: MutableList<InteractionContextType>? by state::contexts.delegate()
@Deprecated("'defaultPermission' is deprecated in favor of 'defaultMemberPermissions' and 'dmPermission'. Setting 'defaultPermission' to false can be replaced by setting 'defaultMemberPermissions' to empty Permissions and 'dmPermission' to false ('dmPermission' is only available for global commands).")
override var defaultPermission: Boolean? by @Suppress("DEPRECATION") state::defaultPermission.delegate()

Expand All @@ -40,6 +41,8 @@ internal class UserCommandModifyBuilderImpl : GlobalUserCommandModifyBuilder {
dmPermission = state.dmPermission,
defaultMemberPermissions = state.defaultMemberPermissions,
defaultPermission = @Suppress("DEPRECATION") state.defaultPermission,
integrationTypes = state.integrationTypes,
contexts = state.contexts,
nsfw = state.nsfw,
)
}
Expand Down Expand Up @@ -78,6 +81,8 @@ internal class UserCommandCreateBuilderImpl(override var name: String) : GlobalU
defaultMemberPermissions = state.defaultMemberPermissions,
dmPermission = state.dmPermission,
defaultPermission = @Suppress("DEPRECATION") state.defaultPermission,
integrationTypes = state.integrationTypes,
contexts = state.contexts,
nsfw = state.nsfw,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public data class ApplicationCommandCreateRequest(
@Deprecated("'defaultPermission' is deprecated in favor of 'defaultMemberPermissions' and 'dmPermission'. Setting 'defaultPermission' to false can be replaced by setting 'defaultMemberPermissions' to empty Permissions and 'dmPermission' to false ('dmPermission' is only available for global commands).")
@SerialName("default_permission")
val defaultPermission: OptionalBoolean = OptionalBoolean.Missing,
@SerialName("integration_types")
val integrationTypes: Optional<List<ApplicationIntegrationType>> = Optional.Missing(),
val contexts: Optional<List<InteractionContextType>?> = Optional.Missing(),
val nsfw: OptionalBoolean = OptionalBoolean.Missing,
)

Expand All @@ -44,6 +47,9 @@ public data class ApplicationCommandModifyRequest(
@Deprecated("'defaultPermission' is deprecated in favor of 'defaultMemberPermissions' and 'dmPermission'. Setting 'defaultPermission' to false can be replaced by setting 'defaultMemberPermissions' to empty Permissions and 'dmPermission' to false ('dmPermission' is only available for global commands).")
@SerialName("default_permission")
val defaultPermission: OptionalBoolean = OptionalBoolean.Missing,
@SerialName("integration_types")
val integrationTypes: Optional<List<ApplicationIntegrationType>> = Optional.Missing(),
val contexts: Optional<List<InteractionContextType>?> = Optional.Missing(),
val nsfw: OptionalBoolean = OptionalBoolean.Missing,
)

Expand Down

0 comments on commit 58410a8

Please sign in to comment.