Skip to content

Commit

Permalink
0.7.3 (#343)
Browse files Browse the repository at this point in the history
* Add a cache aware rest entity supplier (#338)

* add a cahe aware rest supplier/strategy

* abstract the new flow creation for storeAndEmit

* apply suggestions

* Reduce the number of iterations

rename storeAndEmit to storeOnEach

* update changelog

* Fix master gateway average ping conversion (#337)

* Change field visibility and single-expression return syntax (#335)

* changed the visibility for the name, descript.. and type field, changed the toRequest functions to single expression-styled returns

* remade .name and .description to public upon request, kept .type protected

* remade .type into read only (val)

* Implement select menus (#339)

* Add select menu json representation

* Add select menu builders

* add serialization tests for select menu interactions

* Add core implementation of select menus

* Update ButtonComponent docs

* Make SelectMenu min/max values a range

* Fix getGuildBanOrNull recursion (#341)

Fixes the self call in getGuildBanOrNull by delegating the call to the supplier instead

* Make UpdateMessageInteractionResponseCreateBuilder fields nullable (#340)

Makes the fields in the builder and request nullable where appropriate for updating a message

* improve readme

* api dump

* add breaking changes to changelog

* mention the type visibility change

[ci skip]

Co-authored-by: Bart Arys <[email protected]>
Co-authored-by: Noak Palander <[email protected]>
  • Loading branch information
3 people authored Jul 8, 2021
1 parent d81f061 commit df9ad86
Show file tree
Hide file tree
Showing 29 changed files with 1,242 additions and 140 deletions.
31 changes: 30 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# 0.7.3

## Additions

* Add StoreEntitySupplier.
* Add caching rest strategy.
* Add cache-rest caching strategy.
* Add select menus.

## Fixes

* Fix average ping conversion in `MasterGateway`.

## Changes

* Make `UpdateMessageInteractionResponseCreateBuilder` fields nullable.
* type in option builders is now private

## Breaking

* DiscordComponent
* InteractionCallbackData
* ApplicationInteractionData
* ComponentData
* CommandInteraction
* OptionsBuilder
* UpdateMessageInteractionResponseCreateBuilder


# 0.7.2

## Additions
Expand All @@ -11,7 +40,7 @@
## Fixes

* Mentionable arguments now correctly retrieve their entity.
* `Intent#values` emitting null when filtering.
* `Intent.values` emitting null when filtering.

# 0.7.1

Expand Down
62 changes: 52 additions & 10 deletions common/api/common.api
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,10 @@ public final class dev/kord/common/entity/ComponentType$Button : dev/kord/common
public static final field INSTANCE Ldev/kord/common/entity/ComponentType$Button;
}

public final class dev/kord/common/entity/ComponentType$SelectMenu : dev/kord/common/entity/ComponentType {
public static final field INSTANCE Ldev/kord/common/entity/ComponentType$SelectMenu;
}

public final class dev/kord/common/entity/ComponentType$Serializer : kotlinx/serialization/KSerializer {
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/kord/common/entity/ComponentType;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
Expand Down Expand Up @@ -1668,25 +1672,33 @@ public final class dev/kord/common/entity/DiscordClientStatus$Companion {

public final class dev/kord/common/entity/DiscordComponent {
public static final field Companion Ldev/kord/common/entity/DiscordComponent$Companion;
public synthetic fun <init> (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;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (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;)V
public synthetic fun <init> (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;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (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;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (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;)V
public synthetic fun <init> (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;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 component12 ()Ldev/kord/common/entity/optional/OptionalInt;
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;
public final fun component5 ()Ldev/kord/common/entity/optional/Optional;
public final fun component6 ()Ldev/kord/common/entity/optional/Optional;
public final fun component7 ()Ldev/kord/common/entity/optional/OptionalBoolean;
public final fun component8 ()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/DiscordComponent;
public static synthetic fun copy$default (Ldev/kord/common/entity/DiscordComponent;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;ILjava/lang/Object;)Ldev/kord/common/entity/DiscordComponent;
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/DiscordComponent;
public static synthetic fun copy$default (Ldev/kord/common/entity/DiscordComponent;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;ILjava/lang/Object;)Ldev/kord/common/entity/DiscordComponent;
public fun equals (Ljava/lang/Object;)Z
public final fun getComponents ()Ldev/kord/common/entity/optional/Optional;
public final fun getCustomId ()Ldev/kord/common/entity/optional/Optional;
public final fun getDisabled ()Ldev/kord/common/entity/optional/OptionalBoolean;
public final fun getEmoji ()Ldev/kord/common/entity/optional/Optional;
public final fun getLabel ()Ldev/kord/common/entity/optional/Optional;
public final fun getMaxValues ()Ldev/kord/common/entity/optional/OptionalInt;
public final fun getMinValues ()Ldev/kord/common/entity/optional/OptionalInt;
public final fun getOptions ()Ldev/kord/common/entity/optional/Optional;
public final fun getPlaceholder ()Ldev/kord/common/entity/optional/Optional;
public final fun getStyle ()Ldev/kord/common/entity/optional/Optional;
public final fun getType ()Ldev/kord/common/entity/ComponentType;
public final fun getUrl ()Ldev/kord/common/entity/optional/Optional;
Expand Down Expand Up @@ -3636,6 +3648,34 @@ public final class dev/kord/common/entity/DiscordRoleTags$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 <init> (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
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;)V
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getDefault ()Ldev/kord/common/entity/optional/OptionalBoolean;
public final fun getDescription ()Ldev/kord/common/entity/optional/Optional;
public final fun getEmoji ()Ldev/kord/common/entity/optional/Optional;
public final fun getLabel ()Ljava/lang/String;
public final fun getValue ()Ljava/lang/String;
}

public final class dev/kord/common/entity/DiscordSelectOption$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Ldev/kord/common/entity/DiscordSelectOption$$serializer;
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/kord/common/entity/DiscordSelectOption;
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/DiscordSelectOption;)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/DiscordSelectOption$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public final class dev/kord/common/entity/DiscordShard {
public static final field Companion Ldev/kord/common/entity/DiscordShard$Companion;
public fun <init> (II)V
Expand Down Expand Up @@ -4474,24 +4514,26 @@ public final class dev/kord/common/entity/IntegrationExpireBehavior$Unknown : de
public final class dev/kord/common/entity/InteractionCallbackData {
public static final field Companion Ldev/kord/common/entity/InteractionCallbackData$Companion;
public fun <init> ()V
public synthetic fun <init> (ILdev/kord/common/entity/optional/OptionalSnowflake;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;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ldev/kord/common/entity/optional/OptionalSnowflake;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;)V
public synthetic fun <init> (Ldev/kord/common/entity/optional/OptionalSnowflake;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;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (ILdev/kord/common/entity/optional/OptionalSnowflake;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/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ldev/kord/common/entity/optional/OptionalSnowflake;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/Optional;)V
public synthetic fun <init> (Ldev/kord/common/entity/optional/OptionalSnowflake;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/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ldev/kord/common/entity/optional/OptionalSnowflake;
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;
public final fun component5 ()Ldev/kord/common/entity/optional/Optional;
public final fun component6 ()Ldev/kord/common/entity/optional/Optional;
public final fun copy (Ldev/kord/common/entity/optional/OptionalSnowflake;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/InteractionCallbackData;
public static synthetic fun copy$default (Ldev/kord/common/entity/InteractionCallbackData;Ldev/kord/common/entity/optional/OptionalSnowflake;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;ILjava/lang/Object;)Ldev/kord/common/entity/InteractionCallbackData;
public final fun component7 ()Ldev/kord/common/entity/optional/Optional;
public final fun copy (Ldev/kord/common/entity/optional/OptionalSnowflake;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/Optional;)Ldev/kord/common/entity/InteractionCallbackData;
public static synthetic fun copy$default (Ldev/kord/common/entity/InteractionCallbackData;Ldev/kord/common/entity/optional/OptionalSnowflake;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/Optional;ILjava/lang/Object;)Ldev/kord/common/entity/InteractionCallbackData;
public fun equals (Ljava/lang/Object;)Z
public final fun getComponentType ()Ldev/kord/common/entity/optional/Optional;
public final fun getCustomId ()Ldev/kord/common/entity/optional/Optional;
public final fun getId ()Ldev/kord/common/entity/optional/OptionalSnowflake;
public final fun getName ()Ldev/kord/common/entity/optional/Optional;
public final fun getOptions ()Ldev/kord/common/entity/optional/Optional;
public final fun getResolved ()Ldev/kord/common/entity/optional/Optional;
public final fun getValues ()Ldev/kord/common/entity/optional/Optional;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
Expand Down
20 changes: 19 additions & 1 deletion common/src/main/kotlin/entity/DiscordComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dev.kord.common.entity
import dev.kord.common.annotation.KordPreview
import dev.kord.common.entity.optional.Optional
import dev.kord.common.entity.optional.OptionalBoolean
import dev.kord.common.entity.optional.OptionalInt
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand All @@ -11,6 +12,7 @@ import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.JsonNames

/**
* Represent a [intractable component within a message sent in Discord](https://discord.com/developers/docs/interactions/message-components#what-are-components).
Expand All @@ -23,6 +25,10 @@ import kotlinx.serialization.encoding.Encoder
* @property url a url for link-style buttons
* @property disabled whether the button is disabled, default `false`
* @property components a list of child components (for action rows)
* @property options the select menu options
* @property placeholder the placeholder text for the select menu
* @property minValues the minimum amount of [options] allowed
* @property maxValues the maximum amount of [options] allowed
*/
@KordPreview
@Serializable
Expand All @@ -35,7 +41,13 @@ data class DiscordComponent(
val customId: Optional<String> = Optional.Missing(),
val url: Optional<String> = Optional.Missing(),
val disabled: OptionalBoolean = OptionalBoolean.Missing,
val components: Optional<List<DiscordComponent>> = Optional.Missing()
val components: Optional<List<DiscordComponent>> = Optional.Missing(),
val options: Optional<List<DiscordSelectOption>> = Optional.Missing(),
val placeholder: Optional<String> = Optional.Missing(),
@SerialName("min_values")
val minValues: OptionalInt = OptionalInt.Missing,
@SerialName("max_values")
val maxValues: OptionalInt = OptionalInt.Missing,
)

/**
Expand All @@ -62,13 +74,19 @@ sealed class ComponentType(val value: Int) {
*/
object Button : ComponentType(2)

/**
* A select menu for picking from choices.
*/
object SelectMenu : ComponentType(3)

companion object Serializer : KSerializer<ComponentType> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("ComponentType", PrimitiveKind.INT)

override fun deserialize(decoder: Decoder): ComponentType =
when (val value = decoder.decodeInt()) {
1 -> ActionRow
2 -> Button
3 -> SelectMenu
else -> Unknown(value)
}

Expand Down
23 changes: 23 additions & 0 deletions common/src/main/kotlin/entity/DiscordSelectOption.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package dev.kord.common.entity

import dev.kord.common.entity.optional.Optional
import dev.kord.common.entity.optional.OptionalBoolean
import kotlinx.serialization.Serializable

/**
* Represent a [select option structure](https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure).
*
* @param label the user-facing name of the option, max 25 characters
* @param value the dev-define value of the option, max 100 characters
* @param description an additional description of the option, max 50 characters
* @param emoji the emoji to show in the option
* @param default whether to render this option as selected by default
*/
@Serializable
class DiscordSelectOption(
val label: String,
val value: String,
val description: Optional<String> = Optional.Missing(),
val emoji: Optional<DiscordPartialEmoji> = Optional.Missing(),
val default: OptionalBoolean = OptionalBoolean.Missing,
)
Loading

0 comments on commit df9ad86

Please sign in to comment.