diff --git a/CHANGELOG.md b/CHANGELOG.md index ece57b24d08..62667c103f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# 0.7.4 + +## Changes + +* Promote user property in component interaction to a data object. + +## Fixes + +* Fixed `ComponentInteraction#user` throwing a `NullPointerException` when the interaction was created in a direct message. + # 0.7.3 ## Additions diff --git a/core/api/core.api b/core/api/core.api index f6c4968d527..6295810ef6d 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -5735,7 +5735,8 @@ public abstract class dev/kord/core/entity/interaction/ComponentInteraction : de public abstract fun getComponent ()Ldev/kord/core/entity/component/Component; public final fun getComponentId ()Ljava/lang/String; public final fun getMessage ()Ldev/kord/core/entity/Message; - public fun getUser ()Ldev/kord/core/behavior/UserBehavior; + public synthetic fun getUser ()Ldev/kord/core/behavior/UserBehavior; + public fun getUser ()Ldev/kord/core/entity/User; public fun hashCode ()I public abstract fun toString ()Ljava/lang/String; public abstract fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/interaction/ComponentInteraction; diff --git a/core/src/main/kotlin/entity/interaction/ComponentInteraction.kt b/core/src/main/kotlin/entity/interaction/ComponentInteraction.kt index b90cc839fbd..4ee5eec4e9c 100644 --- a/core/src/main/kotlin/entity/interaction/ComponentInteraction.kt +++ b/core/src/main/kotlin/entity/interaction/ComponentInteraction.kt @@ -3,6 +3,7 @@ package dev.kord.core.entity.interaction import dev.kord.common.annotation.KordPreview import dev.kord.common.entity.ComponentType import dev.kord.common.entity.Snowflake +import dev.kord.common.entity.optional.map import dev.kord.common.entity.optional.orEmpty import dev.kord.common.entity.optional.unwrap import dev.kord.core.Kord @@ -10,6 +11,7 @@ import dev.kord.core.behavior.UserBehavior import dev.kord.core.behavior.interaction.ComponentInteractionBehavior import dev.kord.core.cache.data.InteractionData import dev.kord.core.entity.Message +import dev.kord.core.entity.User import dev.kord.core.entity.component.ActionRowComponent import dev.kord.core.entity.component.ButtonComponent import dev.kord.core.entity.component.Component @@ -27,8 +29,9 @@ import dev.kord.rest.builder.component.SelectMenuBuilder @KordPreview sealed class ComponentInteraction : Interaction(), ComponentInteractionBehavior { - override val user: UserBehavior - get() = UserBehavior(data.member.value!!.userId, kord) + override val user: User + get() = User(data.user.value!!, kord) + /** * The message that contains the interacted component, null if the message is ephemeral.