-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The DSL looks like this: val message = channel.createMessage { actionRow { mentionableSelect("customId") { allowedValues = 0..5 defaultUsers += userId defaultRoles += roleId } } } See discord/discord-api-docs#6442
- Loading branch information
1 parent
a4f7143
commit d537432
Showing
9 changed files
with
412 additions
and
43 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
88 changes: 88 additions & 0 deletions
88
...generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/SelectDefaultValueType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT! | ||
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral", | ||
"SpellCheckingInspection", "GrazieInspection")) | ||
|
||
package dev.kord.common.entity | ||
|
||
import kotlin.LazyThreadSafetyMode.PUBLICATION | ||
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 [SelectDefaultValueType]s in the | ||
* [Discord Developer Documentation](https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-default-value-structure). | ||
*/ | ||
@Serializable(with = SelectDefaultValueType.Serializer::class) | ||
public sealed class SelectDefaultValueType( | ||
/** | ||
* The raw value used by Discord. | ||
*/ | ||
public val `value`: String, | ||
) { | ||
final override fun equals(other: Any?): Boolean = this === other || | ||
(other is SelectDefaultValueType && this.value == other.value) | ||
|
||
final override fun hashCode(): Int = value.hashCode() | ||
|
||
final override fun toString(): String = | ||
if (this is Unknown) "SelectDefaultValueType.Unknown(value=$value)" | ||
else "SelectDefaultValueType.${this::class.simpleName}" | ||
|
||
/** | ||
* An unknown [SelectDefaultValueType]. | ||
* | ||
* This is used as a fallback for [SelectDefaultValueType]s that haven't been added to Kord yet. | ||
*/ | ||
public class Unknown internal constructor( | ||
`value`: String, | ||
) : SelectDefaultValueType(value) | ||
|
||
public object User : SelectDefaultValueType("user") | ||
|
||
public object Role : SelectDefaultValueType("role") | ||
|
||
public object Channel : SelectDefaultValueType("channel") | ||
|
||
internal object Serializer : KSerializer<SelectDefaultValueType> { | ||
override val descriptor: SerialDescriptor = | ||
PrimitiveSerialDescriptor("dev.kord.common.entity.SelectDefaultValueType", | ||
PrimitiveKind.STRING) | ||
|
||
override fun serialize(encoder: Encoder, `value`: SelectDefaultValueType) { | ||
encoder.encodeString(value.value) | ||
} | ||
|
||
override fun deserialize(decoder: Decoder): SelectDefaultValueType = | ||
from(decoder.decodeString()) | ||
} | ||
|
||
public companion object { | ||
/** | ||
* A [List] of all known [SelectDefaultValueType]s. | ||
*/ | ||
public val entries: List<SelectDefaultValueType> by lazy(mode = PUBLICATION) { | ||
listOf( | ||
User, | ||
Role, | ||
Channel, | ||
) | ||
} | ||
|
||
|
||
/** | ||
* Returns an instance of [SelectDefaultValueType] with [SelectDefaultValueType.value] equal | ||
* to the specified [value]. | ||
*/ | ||
public fun from(`value`: String): SelectDefaultValueType = when (value) { | ||
"user" -> User | ||
"role" -> Role | ||
"channel" -> Channel | ||
else -> Unknown(value) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
common/src/commonMain/kotlin/entity/DiscordSelectDefaultValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@file:Generate( | ||
STRING_KORD_ENUM, name = "SelectDefaultValueType", unknownConstructorWasPublic = false, | ||
docUrl = "https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-default-value-structure", | ||
entries = [ | ||
Entry("User", stringValue = "user"), | ||
Entry("Role", stringValue = "role"), | ||
Entry("Channel", stringValue = "channel"), | ||
], | ||
) | ||
|
||
package dev.kord.common.entity | ||
|
||
import dev.kord.ksp.Generate | ||
import dev.kord.ksp.Generate.EntityType.STRING_KORD_ENUM | ||
import dev.kord.ksp.Generate.Entry | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
public data class DiscordSelectDefaultValue( | ||
val id: Snowflake, | ||
val type: SelectDefaultValueType, | ||
) |
Oops, something went wrong.