From cbba5f3ee0413e26aafd4e614bf37d924797a5c9 Mon Sep 17 00:00:00 2001 From: NoComment <67918617+NoComment1105@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:22:34 +0100 Subject: [PATCH] Add interaction channel field (#810) See https://github.com/discord/discord-api-docs/pull/6051 --- common/api/common.api | 24 +++++++++-------- .../commonMain/kotlin/entity/Interactions.kt | 3 ++- core/api/core.api | 26 ++++++++++--------- .../kotlin/cache/data/InteractionData.kt | 4 ++- .../kotlin/entity/interaction/Interaction.kt | 2 +- 5 files changed, 33 insertions(+), 26 deletions(-) diff --git a/common/api/common.api b/common/api/common.api index a2493be761e..3f143644ac3 100644 --- a/common/api/common.api +++ b/common/api/common.api @@ -4189,29 +4189,31 @@ public final class dev/kord/common/entity/DiscordIntegrationsAccount$Companion { public final class dev/kord/common/entity/DiscordInteraction { public static final field Companion Ldev/kord/common/entity/DiscordInteraction$Companion; - public synthetic fun (ILdev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/common/entity/InteractionCallbackData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;ILdev/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 (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/common/entity/InteractionCallbackData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;ILdev/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 (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/common/entity/InteractionCallbackData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;ILdev/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 (ILdev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/common/entity/InteractionCallbackData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;ILdev/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 (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/common/entity/InteractionCallbackData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;ILdev/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 (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/common/entity/InteractionCallbackData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;ILdev/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/Snowflake; - public final fun component10 ()I - public final fun component11 ()Ldev/kord/common/entity/optional/Optional; + public final fun component10 ()Ljava/lang/String; + public final fun component11 ()I public final fun component12 ()Ldev/kord/common/entity/optional/Optional; public final fun component13 ()Ldev/kord/common/entity/optional/Optional; public final fun component14 ()Ldev/kord/common/entity/optional/Optional; + public final fun component15 ()Ldev/kord/common/entity/optional/Optional; public final fun component2 ()Ldev/kord/common/entity/Snowflake; public final fun component3 ()Ldev/kord/common/entity/InteractionType; public final fun component4 ()Ldev/kord/common/entity/InteractionCallbackData; public final fun component5 ()Ldev/kord/common/entity/optional/OptionalSnowflake; - public final fun component6 ()Ldev/kord/common/entity/Snowflake; - public final fun component7 ()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/OptionalSnowflake; public final fun component8 ()Ldev/kord/common/entity/optional/Optional; - public final fun component9 ()Ljava/lang/String; - public final fun copy (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/common/entity/InteractionCallbackData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;ILdev/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/DiscordInteraction; - public static synthetic fun copy$default (Ldev/kord/common/entity/DiscordInteraction;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/common/entity/InteractionCallbackData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;ILdev/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/DiscordInteraction; + public final fun component9 ()Ldev/kord/common/entity/optional/Optional; + public final fun copy (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/common/entity/InteractionCallbackData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;ILdev/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/DiscordInteraction; + public static synthetic fun copy$default (Ldev/kord/common/entity/DiscordInteraction;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/common/entity/InteractionCallbackData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;ILdev/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/DiscordInteraction; public fun equals (Ljava/lang/Object;)Z public final fun getAppPermissions ()Ldev/kord/common/entity/optional/Optional; public final fun getApplicationId ()Ldev/kord/common/entity/Snowflake; - public final fun getChannelId ()Ldev/kord/common/entity/Snowflake; + public final fun getChannel ()Ldev/kord/common/entity/optional/Optional; + public final fun getChannelId ()Ldev/kord/common/entity/optional/OptionalSnowflake; public final fun getData ()Ldev/kord/common/entity/InteractionCallbackData; public final fun getGuildId ()Ldev/kord/common/entity/optional/OptionalSnowflake; public final fun getGuildLocale ()Ldev/kord/common/entity/optional/Optional; diff --git a/common/src/commonMain/kotlin/entity/Interactions.kt b/common/src/commonMain/kotlin/entity/Interactions.kt index 0f8afecc461..f3c078d367a 100644 --- a/common/src/commonMain/kotlin/entity/Interactions.kt +++ b/common/src/commonMain/kotlin/entity/Interactions.kt @@ -258,8 +258,9 @@ public data class DiscordInteraction( val data: InteractionCallbackData, @SerialName("guild_id") val guildId: OptionalSnowflake = OptionalSnowflake.Missing, + val channel: Optional = Optional.Missing(), @SerialName("channel_id") - val channelId: Snowflake, + val channelId: OptionalSnowflake = OptionalSnowflake.Missing, val member: Optional = Optional.Missing(), val user: Optional = Optional.Missing(), val token: String, diff --git a/core/api/core.api b/core/api/core.api index b68ed646723..736f8ca11f3 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -3913,30 +3913,32 @@ public final class dev/kord/core/cache/data/IntegrationsAccountData$Companion { public final class dev/kord/core/cache/data/InteractionData { public static final field Companion Ldev/kord/core/cache/data/InteractionData$Companion; - public synthetic fun (ILdev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/core/cache/data/ApplicationInteractionData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;ILdev/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 (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/core/cache/data/ApplicationInteractionData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;ILdev/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 (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/core/cache/data/ApplicationInteractionData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;ILdev/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 (ILdev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/core/cache/data/ApplicationInteractionData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;ILdev/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 (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/core/cache/data/ApplicationInteractionData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;ILdev/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 (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/core/cache/data/ApplicationInteractionData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;ILdev/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/Snowflake; - public final fun component10 ()Ldev/kord/common/entity/optional/Optional; - public final fun component11 ()I - public final fun component12 ()Ldev/kord/common/entity/optional/Optional; + public final fun component10 ()Ljava/lang/String; + public final fun component11 ()Ldev/kord/common/entity/optional/Optional; + public final fun component12 ()I public final fun component13 ()Ldev/kord/common/entity/optional/Optional; public final fun component14 ()Ldev/kord/common/entity/optional/Optional; public final fun component15 ()Ldev/kord/common/entity/optional/Optional; + public final fun component16 ()Ldev/kord/common/entity/optional/Optional; public final fun component2 ()Ldev/kord/common/entity/Snowflake; public final fun component3 ()Ldev/kord/common/entity/InteractionType; public final fun component4 ()Ldev/kord/core/cache/data/ApplicationInteractionData; public final fun component5 ()Ldev/kord/common/entity/optional/OptionalSnowflake; - public final fun component6 ()Ldev/kord/common/entity/Snowflake; - public final fun component7 ()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/OptionalSnowflake; public final fun component8 ()Ldev/kord/common/entity/optional/Optional; - public final fun component9 ()Ljava/lang/String; - public final fun copy (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/core/cache/data/ApplicationInteractionData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;ILdev/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/core/cache/data/InteractionData; - public static synthetic fun copy$default (Ldev/kord/core/cache/data/InteractionData;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/core/cache/data/ApplicationInteractionData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;ILdev/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/core/cache/data/InteractionData; + public final fun component9 ()Ldev/kord/common/entity/optional/Optional; + public final fun copy (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/core/cache/data/ApplicationInteractionData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;ILdev/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/core/cache/data/InteractionData; + public static synthetic fun copy$default (Ldev/kord/core/cache/data/InteractionData;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/InteractionType;Ldev/kord/core/cache/data/ApplicationInteractionData;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;ILdev/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/core/cache/data/InteractionData; public fun equals (Ljava/lang/Object;)Z public final fun getAppPermissions ()Ldev/kord/common/entity/optional/Optional; public final fun getApplicationId ()Ldev/kord/common/entity/Snowflake; - public final fun getChannelId ()Ldev/kord/common/entity/Snowflake; + public final fun getChannel ()Ldev/kord/common/entity/optional/Optional; + public final fun getChannelId ()Ldev/kord/common/entity/optional/OptionalSnowflake; public final fun getData ()Ldev/kord/core/cache/data/ApplicationInteractionData; public final fun getGuildId ()Ldev/kord/common/entity/optional/OptionalSnowflake; public final fun getGuildLocale ()Ldev/kord/common/entity/optional/Optional; diff --git a/core/src/commonMain/kotlin/cache/data/InteractionData.kt b/core/src/commonMain/kotlin/cache/data/InteractionData.kt index 63444095957..c162309d023 100644 --- a/core/src/commonMain/kotlin/cache/data/InteractionData.kt +++ b/core/src/commonMain/kotlin/cache/data/InteractionData.kt @@ -18,7 +18,8 @@ public data class InteractionData( val type: InteractionType, val data: ApplicationInteractionData, val guildId: OptionalSnowflake = OptionalSnowflake.Missing, - val channelId: Snowflake, + val channel: Optional = Optional.Missing(), + val channelId: OptionalSnowflake = OptionalSnowflake.Missing, val member: Optional = Optional.Missing(), val user: Optional = Optional.Missing(), val token: String, @@ -38,6 +39,7 @@ public data class InteractionData( type, ApplicationInteractionData.from(data, guildId.value), guildId, + channel.map { ChannelData.from(it) }, channelId, member.map { it.toData(it.user.value!!.id, guildId.value!!) }, //borrow user from member if present diff --git a/core/src/commonMain/kotlin/entity/interaction/Interaction.kt b/core/src/commonMain/kotlin/entity/interaction/Interaction.kt index c2a606e855d..b61dcad5167 100644 --- a/core/src/commonMain/kotlin/entity/interaction/Interaction.kt +++ b/core/src/commonMain/kotlin/entity/interaction/Interaction.kt @@ -24,7 +24,7 @@ public sealed interface Interaction : InteractionBehavior { override val applicationId: Snowflake get() = data.applicationId - override val channelId: Snowflake get() = data.channelId + override val channelId: Snowflake get() = data.channel.value?.id ?: data.channelId.value!! override val token: String get() = data.token