From d5374328d70168ec7dbd2e0a4b4492617c74c730 Mon Sep 17 00:00:00 2001 From: Luca Kellermann <47486203+lukellmann@users.noreply.github.com> Date: Sat, 18 Nov 2023 01:01:01 +0100 Subject: [PATCH] Add SelectDefaultValues (#881) The DSL looks like this: val message = channel.createMessage { actionRow { mentionableSelect("customId") { allowedValues = 0..5 defaultUsers += userId defaultRoles += roleId } } } See https://github.com/discord/discord-api-docs/pull/6442 --- common/api/common.api | 98 ++++++++++++++++--- .../common/entity/SelectDefaultValueType.kt | 88 +++++++++++++++++ .../kotlin/entity/DiscordComponent.kt | 6 ++ .../entity/DiscordSelectDefaultValue.kt | 22 +++++ core/api/core.api | 87 ++++++++++++---- .../kotlin/cache/data/ComponentData.kt | 5 + .../entity/component/SelectMenuComponent.kt | 87 +++++++++++++++- rest/api/rest.api | 6 ++ .../builder/component/SelectMenuBuilder.kt | 56 ++++++++++- 9 files changed, 412 insertions(+), 43 deletions(-) create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/SelectDefaultValueType.kt create mode 100644 common/src/commonMain/kotlin/entity/DiscordSelectDefaultValue.kt diff --git a/common/api/common.api b/common/api/common.api index 919622cb1a23..12a2afcdefae 100644 --- a/common/api/common.api +++ b/common/api/common.api @@ -3246,18 +3246,19 @@ public final class dev/kord/common/entity/DiscordChannelKt { public final class dev/kord/common/entity/DiscordChatComponent : dev/kord/common/entity/DiscordComponent { public static final field Companion Ldev/kord/common/entity/DiscordChatComponent$Companion; - public synthetic fun (ILdev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (ILdev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V + public synthetic fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/common/entity/ComponentType; public final fun component10 ()Ldev/kord/common/entity/optional/Optional; - public final fun component11 ()Ldev/kord/common/entity/optional/OptionalInt; + public final fun component11 ()Ldev/kord/common/entity/optional/Optional; public final fun component12 ()Ldev/kord/common/entity/optional/OptionalInt; public final fun component13 ()Ldev/kord/common/entity/optional/OptionalInt; public final fun component14 ()Ldev/kord/common/entity/optional/OptionalInt; - public final fun component15 ()Ldev/kord/common/entity/optional/OptionalBoolean; - public final fun component16 ()Ldev/kord/common/entity/optional/Optional; + public final fun component15 ()Ldev/kord/common/entity/optional/OptionalInt; + public final fun component16 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component17 ()Ldev/kord/common/entity/optional/Optional; + public final fun component18 ()Ldev/kord/common/entity/optional/Optional; public final fun component2 ()Ldev/kord/common/entity/optional/Optional; public final fun component3 ()Ldev/kord/common/entity/optional/Optional; public final fun component4 ()Ldev/kord/common/entity/optional/Optional; @@ -3266,12 +3267,13 @@ public final class dev/kord/common/entity/DiscordChatComponent : dev/kord/common public final fun component7 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component8 ()Ldev/kord/common/entity/optional/Optional; public final fun component9 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/common/entity/DiscordChatComponent; - public static synthetic fun copy$default (Ldev/kord/common/entity/DiscordChatComponent;Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/common/entity/DiscordChatComponent; + public final fun copy (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/common/entity/DiscordChatComponent; + public static synthetic fun copy$default (Ldev/kord/common/entity/DiscordChatComponent;Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/common/entity/DiscordChatComponent; public fun equals (Ljava/lang/Object;)Z public fun getChannelTypes ()Ldev/kord/common/entity/optional/Optional; public fun getComponents ()Ldev/kord/common/entity/optional/Optional; public fun getCustomId ()Ldev/kord/common/entity/optional/Optional; + public fun getDefaultValues ()Ldev/kord/common/entity/optional/Optional; public fun getDisabled ()Ldev/kord/common/entity/optional/OptionalBoolean; public fun getEmoji ()Ldev/kord/common/entity/optional/Optional; public fun getLabel ()Ldev/kord/common/entity/optional/Optional; @@ -3346,6 +3348,7 @@ public abstract class dev/kord/common/entity/DiscordComponent { public abstract fun getChannelTypes ()Ldev/kord/common/entity/optional/Optional; public abstract fun getComponents ()Ldev/kord/common/entity/optional/Optional; public abstract fun getCustomId ()Ldev/kord/common/entity/optional/Optional; + public abstract fun getDefaultValues ()Ldev/kord/common/entity/optional/Optional; public abstract fun getDisabled ()Ldev/kord/common/entity/optional/OptionalBoolean; public abstract fun getEmoji ()Ldev/kord/common/entity/optional/Optional; public abstract fun getLabel ()Ldev/kord/common/entity/optional/Optional; @@ -5716,6 +5719,37 @@ public final class dev/kord/common/entity/DiscordRoleTags$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class dev/kord/common/entity/DiscordSelectDefaultValue { + public static final field Companion Ldev/kord/common/entity/DiscordSelectDefaultValue$Companion; + public synthetic fun (ILdev/kord/common/entity/Snowflake;Ldev/kord/common/entity/SelectDefaultValueType;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public fun (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/SelectDefaultValueType;)V + public final fun component1 ()Ldev/kord/common/entity/Snowflake; + public final fun component2 ()Ldev/kord/common/entity/SelectDefaultValueType; + public final fun copy (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/SelectDefaultValueType;)Ldev/kord/common/entity/DiscordSelectDefaultValue; + public static synthetic fun copy$default (Ldev/kord/common/entity/DiscordSelectDefaultValue;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/SelectDefaultValueType;ILjava/lang/Object;)Ldev/kord/common/entity/DiscordSelectDefaultValue; + public fun equals (Ljava/lang/Object;)Z + public final fun getId ()Ldev/kord/common/entity/Snowflake; + public final fun getType ()Ldev/kord/common/entity/SelectDefaultValueType; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; + public static final synthetic fun write$Self (Ldev/kord/common/entity/DiscordSelectDefaultValue;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V +} + +public final class dev/kord/common/entity/DiscordSelectDefaultValue$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/kord/common/entity/DiscordSelectDefaultValue$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/kord/common/entity/DiscordSelectDefaultValue; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/kord/common/entity/DiscordSelectDefaultValue;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/kord/common/entity/DiscordSelectDefaultValue$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/kord/common/entity/DiscordSelectOption { public static final field Companion Ldev/kord/common/entity/DiscordSelectOption$Companion; public synthetic fun (ILjava/lang/String;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V @@ -6021,18 +6055,19 @@ public final class dev/kord/common/entity/DiscordTemplate$Companion { public final class dev/kord/common/entity/DiscordTextInputComponent : dev/kord/common/entity/DiscordComponent { public static final field Companion Ldev/kord/common/entity/DiscordTextInputComponent$Companion; - public synthetic fun (ILdev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (ILdev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V + public synthetic fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/common/entity/ComponentType; public final fun component10 ()Ldev/kord/common/entity/optional/Optional; - public final fun component11 ()Ldev/kord/common/entity/optional/OptionalInt; + public final fun component11 ()Ldev/kord/common/entity/optional/Optional; public final fun component12 ()Ldev/kord/common/entity/optional/OptionalInt; public final fun component13 ()Ldev/kord/common/entity/optional/OptionalInt; public final fun component14 ()Ldev/kord/common/entity/optional/OptionalInt; - public final fun component15 ()Ldev/kord/common/entity/optional/OptionalBoolean; - public final fun component16 ()Ldev/kord/common/entity/optional/Optional; + public final fun component15 ()Ldev/kord/common/entity/optional/OptionalInt; + public final fun component16 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component17 ()Ldev/kord/common/entity/optional/Optional; + public final fun component18 ()Ldev/kord/common/entity/optional/Optional; public final fun component2 ()Ldev/kord/common/entity/optional/Optional; public final fun component3 ()Ldev/kord/common/entity/optional/Optional; public final fun component4 ()Ldev/kord/common/entity/optional/Optional; @@ -6041,12 +6076,13 @@ public final class dev/kord/common/entity/DiscordTextInputComponent : dev/kord/c public final fun component7 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component8 ()Ldev/kord/common/entity/optional/Optional; public final fun component9 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/common/entity/DiscordTextInputComponent; - public static synthetic fun copy$default (Ldev/kord/common/entity/DiscordTextInputComponent;Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/common/entity/DiscordTextInputComponent; + public final fun copy (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/common/entity/DiscordTextInputComponent; + public static synthetic fun copy$default (Ldev/kord/common/entity/DiscordTextInputComponent;Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/common/entity/DiscordTextInputComponent; public fun equals (Ljava/lang/Object;)Z public fun getChannelTypes ()Ldev/kord/common/entity/optional/Optional; public fun getComponents ()Ldev/kord/common/entity/optional/Optional; public fun getCustomId ()Ldev/kord/common/entity/optional/Optional; + public fun getDefaultValues ()Ldev/kord/common/entity/optional/Optional; public fun getDisabled ()Ldev/kord/common/entity/optional/OptionalBoolean; public fun getEmoji ()Ldev/kord/common/entity/optional/Optional; public fun getLabel ()Ldev/kord/common/entity/optional/Optional; @@ -8597,6 +8633,36 @@ public final class dev/kord/common/entity/ScheduledEntityType$Voice : dev/kord/c public static final field INSTANCE Ldev/kord/common/entity/ScheduledEntityType$Voice; } +public abstract class dev/kord/common/entity/SelectDefaultValueType { + public static final field Companion Ldev/kord/common/entity/SelectDefaultValueType$Companion; + public synthetic fun (Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun equals (Ljava/lang/Object;)Z + public final fun getValue ()Ljava/lang/String; + public final fun hashCode ()I + public final fun toString ()Ljava/lang/String; +} + +public final class dev/kord/common/entity/SelectDefaultValueType$Channel : dev/kord/common/entity/SelectDefaultValueType { + public static final field INSTANCE Ldev/kord/common/entity/SelectDefaultValueType$Channel; +} + +public final class dev/kord/common/entity/SelectDefaultValueType$Companion { + public final fun from (Ljava/lang/String;)Ldev/kord/common/entity/SelectDefaultValueType; + public final fun getEntries ()Ljava/util/List; + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/kord/common/entity/SelectDefaultValueType$Role : dev/kord/common/entity/SelectDefaultValueType { + public static final field INSTANCE Ldev/kord/common/entity/SelectDefaultValueType$Role; +} + +public final class dev/kord/common/entity/SelectDefaultValueType$Unknown : dev/kord/common/entity/SelectDefaultValueType { +} + +public final class dev/kord/common/entity/SelectDefaultValueType$User : dev/kord/common/entity/SelectDefaultValueType { + public static final field INSTANCE Ldev/kord/common/entity/SelectDefaultValueType$User; +} + public final class dev/kord/common/entity/Snowflake : java/lang/Comparable { public static final field Companion Ldev/kord/common/entity/Snowflake$Companion; public synthetic fun (JLkotlin/jvm/internal/DefaultConstructorMarker;)V diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/SelectDefaultValueType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/SelectDefaultValueType.kt new file mode 100644 index 000000000000..89ed6def8125 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/SelectDefaultValueType.kt @@ -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 { + 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 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) + } + } +} diff --git a/common/src/commonMain/kotlin/entity/DiscordComponent.kt b/common/src/commonMain/kotlin/entity/DiscordComponent.kt index 4db9de9af771..e9ee92527959 100644 --- a/common/src/commonMain/kotlin/entity/DiscordComponent.kt +++ b/common/src/commonMain/kotlin/entity/DiscordComponent.kt @@ -80,6 +80,8 @@ public sealed class DiscordComponent { public abstract val components: Optional> public abstract val options: Optional> public abstract val placeholder: Optional + @SerialName("default_values") + public abstract val defaultValues: Optional> @SerialName("min_values") public abstract val minValues: OptionalInt @SerialName("max_values") @@ -119,6 +121,8 @@ public data class DiscordChatComponent( override val components: Optional> = Optional.Missing(), override val options: Optional> = Optional.Missing(), override val placeholder: Optional = Optional.Missing(), + @SerialName("default_values") + override val defaultValues: Optional> = Optional.Missing(), @SerialName("min_values") override val minValues: OptionalInt = OptionalInt.Missing, @SerialName("max_values") @@ -146,6 +150,8 @@ public data class DiscordTextInputComponent( override val components: Optional> = Optional.Missing(), override val options: Optional> = Optional.Missing(), override val placeholder: Optional = Optional.Missing(), + @SerialName("default_values") + override val defaultValues: Optional> = Optional.Missing(), @SerialName("min_values") override val minValues: OptionalInt = OptionalInt.Missing, @SerialName("max_values") diff --git a/common/src/commonMain/kotlin/entity/DiscordSelectDefaultValue.kt b/common/src/commonMain/kotlin/entity/DiscordSelectDefaultValue.kt new file mode 100644 index 000000000000..e59c21c1cb37 --- /dev/null +++ b/common/src/commonMain/kotlin/entity/DiscordSelectDefaultValue.kt @@ -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, +) diff --git a/core/api/core.api b/core/api/core.api index 3805ed74e66d..fc5739932b08 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -3097,18 +3097,19 @@ public final class dev/kord/core/cache/data/ChannelDataKt { public final class dev/kord/core/cache/data/ChatComponentData : dev/kord/core/cache/data/ComponentData { public static final field Companion Ldev/kord/core/cache/data/ChatComponentData$Companion; - public synthetic fun (ILdev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (ILdev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V + public synthetic fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/common/entity/ComponentType; - public final fun component10 ()Ldev/kord/common/entity/optional/OptionalInt; + public final fun component10 ()Ldev/kord/common/entity/optional/Optional; public final fun component11 ()Ldev/kord/common/entity/optional/OptionalInt; - public final fun component12 ()Ldev/kord/common/entity/optional/Optional; - public final fun component13 ()Ldev/kord/common/entity/optional/OptionalInt; + public final fun component12 ()Ldev/kord/common/entity/optional/OptionalInt; + public final fun component13 ()Ldev/kord/common/entity/optional/Optional; public final fun component14 ()Ldev/kord/common/entity/optional/OptionalInt; - public final fun component15 ()Ldev/kord/common/entity/optional/OptionalBoolean; - public final fun component16 ()Ldev/kord/common/entity/optional/Optional; + public final fun component15 ()Ldev/kord/common/entity/optional/OptionalInt; + public final fun component16 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component17 ()Ldev/kord/common/entity/optional/Optional; + public final fun component18 ()Ldev/kord/common/entity/optional/Optional; public final fun component2 ()Ldev/kord/common/entity/optional/Optional; public final fun component3 ()Ldev/kord/common/entity/optional/Optional; public final fun component4 ()Ldev/kord/common/entity/optional/Optional; @@ -3117,12 +3118,13 @@ public final class dev/kord/core/cache/data/ChatComponentData : dev/kord/core/ca public final fun component7 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component8 ()Ldev/kord/common/entity/optional/Optional; public final fun component9 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/core/cache/data/ChatComponentData; - public static synthetic fun copy$default (Ldev/kord/core/cache/data/ChatComponentData;Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/core/cache/data/ChatComponentData; + public final fun copy (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/core/cache/data/ChatComponentData; + public static synthetic fun copy$default (Ldev/kord/core/cache/data/ChatComponentData;Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/core/cache/data/ChatComponentData; public fun equals (Ljava/lang/Object;)Z public fun getChannelTypes ()Ldev/kord/common/entity/optional/Optional; public fun getComponents ()Ldev/kord/common/entity/optional/Optional; public fun getCustomId ()Ldev/kord/common/entity/optional/Optional; + public fun getDefaultValues ()Ldev/kord/common/entity/optional/Optional; public fun getDisabled ()Ldev/kord/common/entity/optional/OptionalBoolean; public fun getEmoji ()Ldev/kord/common/entity/optional/Optional; public fun getLabel ()Ldev/kord/common/entity/optional/Optional; @@ -3199,6 +3201,7 @@ public abstract class dev/kord/core/cache/data/ComponentData { public abstract fun getChannelTypes ()Ldev/kord/common/entity/optional/Optional; public abstract fun getComponents ()Ldev/kord/common/entity/optional/Optional; public abstract fun getCustomId ()Ldev/kord/common/entity/optional/Optional; + public abstract fun getDefaultValues ()Ldev/kord/common/entity/optional/Optional; public abstract fun getDisabled ()Ldev/kord/common/entity/optional/OptionalBoolean; public abstract fun getEmoji ()Ldev/kord/common/entity/optional/Optional; public abstract fun getLabel ()Ldev/kord/common/entity/optional/Optional; @@ -5369,18 +5372,19 @@ public final class dev/kord/core/cache/data/TemplateDataKt { public final class dev/kord/core/cache/data/TextInputComponentData : dev/kord/core/cache/data/ComponentData { public static final field Companion Ldev/kord/core/cache/data/TextInputComponentData$Companion; - public synthetic fun (ILdev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (ILdev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V + public synthetic fun (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/common/entity/ComponentType; - public final fun component10 ()Ldev/kord/common/entity/optional/OptionalInt; + public final fun component10 ()Ldev/kord/common/entity/optional/Optional; public final fun component11 ()Ldev/kord/common/entity/optional/OptionalInt; - public final fun component12 ()Ldev/kord/common/entity/optional/Optional; - public final fun component13 ()Ldev/kord/common/entity/optional/OptionalInt; + public final fun component12 ()Ldev/kord/common/entity/optional/OptionalInt; + public final fun component13 ()Ldev/kord/common/entity/optional/Optional; public final fun component14 ()Ldev/kord/common/entity/optional/OptionalInt; - public final fun component15 ()Ldev/kord/common/entity/optional/OptionalBoolean; - public final fun component16 ()Ldev/kord/common/entity/optional/Optional; + public final fun component15 ()Ldev/kord/common/entity/optional/OptionalInt; + public final fun component16 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component17 ()Ldev/kord/common/entity/optional/Optional; + public final fun component18 ()Ldev/kord/common/entity/optional/Optional; public final fun component2 ()Ldev/kord/common/entity/optional/Optional; public final fun component3 ()Ldev/kord/common/entity/optional/Optional; public final fun component4 ()Ldev/kord/common/entity/optional/Optional; @@ -5389,12 +5393,13 @@ public final class dev/kord/core/cache/data/TextInputComponentData : dev/kord/co public final fun component7 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component8 ()Ldev/kord/common/entity/optional/Optional; public final fun component9 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/core/cache/data/TextInputComponentData; - public static synthetic fun copy$default (Ldev/kord/core/cache/data/TextInputComponentData;Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/core/cache/data/TextInputComponentData; + public final fun copy (Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/core/cache/data/TextInputComponentData; + public static synthetic fun copy$default (Ldev/kord/core/cache/data/TextInputComponentData;Ldev/kord/common/entity/ComponentType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/core/cache/data/TextInputComponentData; public fun equals (Ljava/lang/Object;)Z public fun getChannelTypes ()Ldev/kord/common/entity/optional/Optional; public fun getComponents ()Ldev/kord/common/entity/optional/Optional; public fun getCustomId ()Ldev/kord/common/entity/optional/Optional; + public fun getDefaultValues ()Ldev/kord/common/entity/optional/Optional; public fun getDisabled ()Ldev/kord/common/entity/optional/OptionalBoolean; public fun getEmoji ()Ldev/kord/common/entity/optional/Optional; public fun getLabel ()Ldev/kord/common/entity/optional/Optional; @@ -9105,6 +9110,7 @@ public final class dev/kord/core/entity/component/ButtonComponent : dev/kord/cor public final class dev/kord/core/entity/component/ChannelSelectComponent : dev/kord/core/entity/component/SelectMenuComponent { public fun (Ldev/kord/core/cache/data/ComponentData;)V public final fun getChannelTypes ()Ljava/util/List; + public final fun getDefaultValues ()Ljava/util/List; public fun getType ()Ldev/kord/common/entity/ComponentType$StringSelect; public synthetic fun getType ()Ldev/kord/common/entity/ComponentType; } @@ -9124,16 +9130,56 @@ public final class dev/kord/core/entity/component/ComponentKt { public final class dev/kord/core/entity/component/MentionableSelectComponent : dev/kord/core/entity/component/SelectMenuComponent { public fun (Ldev/kord/core/cache/data/ComponentData;)V + public final fun getDefaultValues ()Ljava/util/List; public fun getType ()Ldev/kord/common/entity/ComponentType$MentionableSelect; public synthetic fun getType ()Ldev/kord/common/entity/ComponentType; } public final class dev/kord/core/entity/component/RoleSelectComponent : dev/kord/core/entity/component/SelectMenuComponent { public fun (Ldev/kord/core/cache/data/ComponentData;)V + public final fun getDefaultValues ()Ljava/util/List; public fun getType ()Ldev/kord/common/entity/ComponentType$RoleSelect; public synthetic fun getType ()Ldev/kord/common/entity/ComponentType; } +public abstract interface class dev/kord/core/entity/component/SelectDefaultValue { + public abstract fun getId ()Ldev/kord/common/entity/Snowflake; + public abstract fun getType ()Ldev/kord/common/entity/SelectDefaultValueType; +} + +public final class dev/kord/core/entity/component/SelectDefaultValue$Channel : dev/kord/core/entity/component/SelectDefaultValue { + public fun (Ldev/kord/common/entity/Snowflake;)V + public fun equals (Ljava/lang/Object;)Z + public fun getId ()Ldev/kord/common/entity/Snowflake; + public fun getType ()Ldev/kord/common/entity/SelectDefaultValueType$Channel; + public synthetic fun getType ()Ldev/kord/common/entity/SelectDefaultValueType; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public abstract interface class dev/kord/core/entity/component/SelectDefaultValue$Mentionable : dev/kord/core/entity/component/SelectDefaultValue { +} + +public final class dev/kord/core/entity/component/SelectDefaultValue$Role : dev/kord/core/entity/component/SelectDefaultValue$Mentionable { + public fun (Ldev/kord/common/entity/Snowflake;)V + public fun equals (Ljava/lang/Object;)Z + public fun getId ()Ldev/kord/common/entity/Snowflake; + public fun getType ()Ldev/kord/common/entity/SelectDefaultValueType$Role; + public synthetic fun getType ()Ldev/kord/common/entity/SelectDefaultValueType; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/kord/core/entity/component/SelectDefaultValue$User : dev/kord/core/entity/component/SelectDefaultValue$Mentionable { + public fun (Ldev/kord/common/entity/Snowflake;)V + public fun equals (Ljava/lang/Object;)Z + public fun getId ()Ldev/kord/common/entity/Snowflake; + public fun getType ()Ldev/kord/common/entity/SelectDefaultValueType$User; + public synthetic fun getType ()Ldev/kord/common/entity/SelectDefaultValueType; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + public abstract class dev/kord/core/entity/component/SelectMenuComponent : dev/kord/core/entity/component/Component { public synthetic fun (Ldev/kord/core/cache/data/ComponentData;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public fun equals (Ljava/lang/Object;)Z @@ -9198,6 +9244,7 @@ public final class dev/kord/core/entity/component/UnknownComponent : dev/kord/co public final class dev/kord/core/entity/component/UserSelectComponent : dev/kord/core/entity/component/SelectMenuComponent { public fun (Ldev/kord/core/cache/data/ComponentData;)V + public final fun getDefaultValues ()Ljava/util/List; public fun getType ()Ldev/kord/common/entity/ComponentType$UserSelect; public synthetic fun getType ()Ldev/kord/common/entity/ComponentType; } diff --git a/core/src/commonMain/kotlin/cache/data/ComponentData.kt b/core/src/commonMain/kotlin/cache/data/ComponentData.kt index a1cf83005236..b840a39a35d3 100644 --- a/core/src/commonMain/kotlin/cache/data/ComponentData.kt +++ b/core/src/commonMain/kotlin/cache/data/ComponentData.kt @@ -21,6 +21,7 @@ public sealed class ComponentData { public abstract val url: Optional public abstract val disabled: OptionalBoolean public abstract val components: Optional> + public abstract val defaultValues: Optional> public abstract val placeholder: Optional public abstract val minValues: OptionalInt public abstract val maxValues: OptionalInt @@ -44,6 +45,7 @@ public sealed class ComponentData { url, disabled, components.mapList { from(it) }, + defaultValues = defaultValues, placeholder = placeholder, minValues = minValues, maxValues = maxValues, @@ -65,6 +67,7 @@ public sealed class ComponentData { url, disabled, components.mapList { from(it) }, + defaultValues = defaultValues, placeholder = placeholder, minValues = minValues, maxValues = maxValues, @@ -92,6 +95,7 @@ public data class ChatComponentData( override val url: Optional = Optional.Missing(), override val disabled: OptionalBoolean = OptionalBoolean.Missing, override val components: Optional> = Optional.Missing(), + override val defaultValues: Optional> = Optional.Missing(), override val placeholder: Optional = Optional.Missing(), override val minValues: OptionalInt = OptionalInt.Missing, override val maxValues: OptionalInt = OptionalInt.Missing, @@ -114,6 +118,7 @@ public data class TextInputComponentData( override val url: Optional = Optional.Missing(), override val disabled: OptionalBoolean = OptionalBoolean.Missing, override val components: Optional> = Optional.Missing(), + override val defaultValues: Optional> = Optional.Missing(), override val placeholder: Optional = Optional.Missing(), override val minValues: OptionalInt = OptionalInt.Missing, override val maxValues: OptionalInt = OptionalInt.Missing, diff --git a/core/src/commonMain/kotlin/entity/component/SelectMenuComponent.kt b/core/src/commonMain/kotlin/entity/component/SelectMenuComponent.kt index d2796074319c..0e84c35ef91f 100644 --- a/core/src/commonMain/kotlin/entity/component/SelectMenuComponent.kt +++ b/core/src/commonMain/kotlin/entity/component/SelectMenuComponent.kt @@ -1,8 +1,6 @@ package dev.kord.core.entity.component -import dev.kord.common.entity.ChannelType -import dev.kord.common.entity.ComponentType -import dev.kord.common.entity.DiscordPartialEmoji +import dev.kord.common.entity.* import dev.kord.common.entity.optional.orEmpty import dev.kord.core.cache.data.ComponentData import dev.kord.core.cache.data.SelectOptionData @@ -67,20 +65,57 @@ public val StringSelectComponent.options: List get() = options public class UserSelectComponent(data: ComponentData) : SelectMenuComponent(data) { override val type: ComponentType.UserSelect get() = ComponentType.UserSelect + + /** The list of [default values][SelectDefaultValue.User] for this select menu. */ + public val defaultValues: List + get() = data.defaultValues.orEmpty().map { + when (val type = it.type) { + SelectDefaultValueType.User -> SelectDefaultValue.User(it.id) + else -> error("Did not expect $type") + } + } } public class RoleSelectComponent(data: ComponentData) : SelectMenuComponent(data) { override val type: ComponentType.RoleSelect get() = ComponentType.RoleSelect + + /** The list of [default values][SelectDefaultValue.Role] for this select menu. */ + public val defaultValues: List + get() = data.defaultValues.orEmpty().map { + when (val type = it.type) { + SelectDefaultValueType.Role -> SelectDefaultValue.Role(it.id) + else -> error("Did not expect $type") + } + } } public class MentionableSelectComponent(data: ComponentData) : SelectMenuComponent(data) { override val type: ComponentType.MentionableSelect get() = ComponentType.MentionableSelect + + /** The list of [default values][SelectDefaultValue.Mentionable] for this select menu. */ + public val defaultValues: List + get() = data.defaultValues.orEmpty().map { + when (val type = it.type) { + SelectDefaultValueType.User -> SelectDefaultValue.User(it.id) + SelectDefaultValueType.Role -> SelectDefaultValue.Role(it.id) + else -> error("Did not expect $type") + } + } } public class ChannelSelectComponent(data: ComponentData) : SelectMenuComponent(data) { override val type: ComponentType.StringSelect get() = ComponentType.StringSelect public val channelTypes: List? get() = data.channelTypes.value + + /** The list of [default values][SelectDefaultValue.Channel] for this select menu. */ + public val defaultValues: List + get() = data.defaultValues.orEmpty().map { + when (val type = it.type) { + SelectDefaultValueType.Channel -> SelectDefaultValue.Channel(it.id) + else -> error("Did not expect $type") + } + } } /** @@ -126,3 +161,49 @@ public class SelectOption(public val data: SelectOptionData) { override fun toString(): String = "SelectOption(data=$data)" } + +/** + * A default value for auto-populated select menu components like [UserSelectComponent], [RoleSelectComponent], + * [MentionableSelectComponent] or [ChannelSelectComponent]. + */ +public sealed interface SelectDefaultValue { + /** + * The ID of a [User][dev.kord.core.entity.User], [Role][dev.kord.core.entity.Role] or + * [Channel][dev.kord.core.entity.channel.Channel]. + */ + public val id: Snowflake + + /** The type of value [id] represents. */ + public val type: SelectDefaultValueType + + /** + * A [SelectDefaultValue] for [MentionableSelectComponent]. + * + * This is a common supertype for [User] and [Role]. + */ + public sealed interface Mentionable : SelectDefaultValue + + /** A [SelectDefaultValue] for [UserSelectComponent]. */ + public class User(override val id: Snowflake) : Mentionable { + override val type: SelectDefaultValueType.User get() = SelectDefaultValueType.User + override fun equals(other: Any?): Boolean = this === other || other is User && this.id == other.id + override fun hashCode(): Int = id.hashCode() + override fun toString(): String = "SelectDefaultValue.User(id=$id)" + } + + /** A [SelectDefaultValue] for [RoleSelectComponent]. */ + public class Role(override val id: Snowflake) : Mentionable { + override val type: SelectDefaultValueType.Role get() = SelectDefaultValueType.Role + override fun equals(other: Any?): Boolean = this === other || other is Role && this.id == other.id + override fun hashCode(): Int = id.hashCode() + override fun toString(): String = "SelectDefaultValue.Role(id=$id)" + } + + /** A [SelectDefaultValue] for [ChannelSelectComponent]. */ + public class Channel(override val id: Snowflake) : SelectDefaultValue { + override val type: SelectDefaultValueType.Channel get() = SelectDefaultValueType.Channel + override fun equals(other: Any?): Boolean = this === other || other is Channel && this.id == other.id + override fun hashCode(): Int = id.hashCode() + override fun toString(): String = "SelectDefaultValue.Channel(id=$id)" + } +} diff --git a/rest/api/rest.api b/rest/api/rest.api index d78ea3fd1456..9f707b202f85 100644 --- a/rest/api/rest.api +++ b/rest/api/rest.api @@ -1046,6 +1046,7 @@ public final class dev/kord/rest/builder/component/ButtonBuilder$LinkButtonBuild public final class dev/kord/rest/builder/component/ChannelSelectBuilder : dev/kord/rest/builder/component/SelectMenuBuilder { public fun (Ljava/lang/String;)V public final fun getChannelTypes ()Ljava/util/List; + public final fun getDefaultChannels ()Ljava/util/List; public final fun setChannelTypes (Ljava/util/List;)V } @@ -1055,6 +1056,8 @@ public abstract interface class dev/kord/rest/builder/component/ComponentBuilder public final class dev/kord/rest/builder/component/MentionableSelectBuilder : dev/kord/rest/builder/component/SelectMenuBuilder { public fun (Ljava/lang/String;)V + public final fun getDefaultRoles ()Ljava/util/List; + public final fun getDefaultUsers ()Ljava/util/List; } public abstract interface class dev/kord/rest/builder/component/MessageComponentBuilder : dev/kord/rest/builder/component/ComponentBuilder { @@ -1062,6 +1065,7 @@ public abstract interface class dev/kord/rest/builder/component/MessageComponent public final class dev/kord/rest/builder/component/RoleSelectBuilder : dev/kord/rest/builder/component/SelectMenuBuilder { public fun (Ljava/lang/String;)V + public final fun getDefaultRoles ()Ljava/util/List; } public abstract class dev/kord/rest/builder/component/SelectMenuBuilder : dev/kord/rest/builder/component/ActionRowComponentBuilder { @@ -1069,6 +1073,7 @@ public abstract class dev/kord/rest/builder/component/SelectMenuBuilder : dev/ko public final fun build ()Ldev/kord/common/entity/DiscordChatComponent; public synthetic fun build ()Ldev/kord/common/entity/DiscordComponent; protected fun buildChannelTypes ()Ldev/kord/common/entity/optional/Optional; + protected fun buildDefaultValues ()Ldev/kord/common/entity/optional/Optional; protected fun buildOptions ()Ldev/kord/common/entity/optional/Optional; public final fun getAllowedValues ()Lkotlin/ranges/ClosedRange; public final fun getCustomId ()Ljava/lang/String; @@ -1130,6 +1135,7 @@ public final class dev/kord/rest/builder/component/TextInputBuilder : dev/kord/r public final class dev/kord/rest/builder/component/UserSelectBuilder : dev/kord/rest/builder/component/SelectMenuBuilder { public fun (Ljava/lang/String;)V + public final fun getDefaultUsers ()Ljava/util/List; } public final class dev/kord/rest/builder/guild/CurrentVoiceStateModifyBuilder : dev/kord/rest/builder/RequestBuilder { diff --git a/rest/src/commonMain/kotlin/builder/component/SelectMenuBuilder.kt b/rest/src/commonMain/kotlin/builder/component/SelectMenuBuilder.kt index 016ebb10a1cf..c1ea5e5f065d 100644 --- a/rest/src/commonMain/kotlin/builder/component/SelectMenuBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/component/SelectMenuBuilder.kt @@ -1,10 +1,8 @@ package dev.kord.rest.builder.component import dev.kord.common.annotation.KordDsl -import dev.kord.common.entity.ChannelType -import dev.kord.common.entity.ComponentType -import dev.kord.common.entity.DiscordChatComponent -import dev.kord.common.entity.DiscordSelectOption +import dev.kord.common.entity.* +import dev.kord.common.entity.SelectDefaultValueType.* import dev.kord.common.entity.optional.Optional import dev.kord.common.entity.optional.OptionalInt import dev.kord.common.entity.optional.delegate.delegate @@ -41,12 +39,14 @@ public sealed class SelectMenuBuilder(public var customId: String) : ActionRowCo protected abstract val type: ComponentType protected open fun buildOptions(): Optional> = Optional.Missing() protected open fun buildChannelTypes(): Optional> = Optional.Missing() + protected open fun buildDefaultValues(): Optional> = Optional.Missing() final override fun build(): DiscordChatComponent = DiscordChatComponent( type = type, customId = Optional(customId), options = buildOptions(), channelTypes = buildChannelTypes(), placeholder = _placeholder, + defaultValues = buildDefaultValues(), minValues = OptionalInt.Value(allowedValues.start), maxValues = OptionalInt.Value(allowedValues.endInclusive), disabled = _disabled, @@ -91,16 +91,55 @@ public inline fun StringSelectBuilder.option( @KordDsl public class UserSelectBuilder(customId: String) : SelectMenuBuilder(customId) { override val type: ComponentType get() = ComponentType.UserSelect + + /** + * The list of default user IDs for this [user select menu][ComponentType.UserSelect]. + * + * The number of default values must be in the range defined by [allowedValues]. + */ + public val defaultUsers: MutableList = mutableListOf() + + override fun buildDefaultValues(): Optional> = + Optional.missingOnEmpty(defaultUsers.map { id -> DiscordSelectDefaultValue(id, type = User) }) } @KordDsl public class RoleSelectBuilder(customId: String) : SelectMenuBuilder(customId) { override val type: ComponentType get() = ComponentType.RoleSelect + + /** + * The list of default role IDs for this [role select menu][ComponentType.RoleSelect]. + * + * The number of default values must be in the range defined by [allowedValues]. + */ + public val defaultRoles: MutableList = mutableListOf() + + override fun buildDefaultValues(): Optional> = + Optional.missingOnEmpty(defaultRoles.map { id -> DiscordSelectDefaultValue(id, type = Role) }) } @KordDsl public class MentionableSelectBuilder(customId: String) : SelectMenuBuilder(customId) { override val type: ComponentType get() = ComponentType.MentionableSelect + + /** + * The list of default user IDs for this [mentionable select menu][ComponentType.MentionableSelect]. + * + * The number of default values must be in the range defined by [allowedValues]. + */ + public val defaultUsers: MutableList = mutableListOf() + + /** + * The list of default role IDs for this [mentionable select menu][ComponentType.MentionableSelect]. + * + * The number of default values must be in the range defined by [allowedValues]. + */ + public val defaultRoles: MutableList = mutableListOf() + + override fun buildDefaultValues(): Optional> = Optional.missingOnEmpty( + defaultUsers.map { id -> DiscordSelectDefaultValue(id, type = User) } + + defaultRoles.map { id -> DiscordSelectDefaultValue(id, type = Role) } + ) } @KordDsl @@ -110,7 +149,16 @@ public class ChannelSelectBuilder(customId: String) : SelectMenuBuilder(customId private var _channelTypes: Optional> = Optional.Missing() public var channelTypes: MutableList? by ::_channelTypes.delegate() + /** + * The list of default channel IDs for this [channel select menu][ComponentType.ChannelSelect]. + * + * The number of default values must be in the range defined by [allowedValues]. + */ + public val defaultChannels: MutableList = mutableListOf() + override fun buildChannelTypes(): Optional> = _channelTypes.mapCopy() + override fun buildDefaultValues(): Optional> = + Optional.missingOnEmpty(defaultChannels.map { id -> DiscordSelectDefaultValue(id, type = Channel) }) } public fun ChannelSelectBuilder.channelType(type: ChannelType) {