From 089de0ccc93f3029fa523a600c7f36a027bd5a32 Mon Sep 17 00:00:00 2001 From: NoComment Date: Wed, 2 Aug 2023 11:11:17 +0100 Subject: [PATCH 1/4] Add `avatar_decoration` to user --- common/api/common.api | 12 +++++++----- common/src/commonMain/kotlin/entity/DiscordUser.kt | 7 ++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/api/common.api b/common/api/common.api index a2493be761ec..e9081fa49947 100644 --- a/common/api/common.api +++ b/common/api/common.api @@ -5983,9 +5983,9 @@ public final class dev/kord/common/entity/DiscordUpdatedGuildMember$Companion { public final class dev/kord/common/entity/DiscordUser { public static final field Companion Ldev/kord/common/entity/DiscordUser$Companion; - public synthetic fun (ILdev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;)V - public synthetic fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (ILdev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;)V + public synthetic fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/common/entity/Snowflake; public final fun component10 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component11 ()Ldev/kord/common/entity/optional/Optional; @@ -5994,6 +5994,7 @@ public final class dev/kord/common/entity/DiscordUser { public final fun component14 ()Ldev/kord/common/entity/optional/Optional; public final fun component15 ()Ljava/lang/String; public final fun component16 ()Ljava/lang/Integer; + public final fun component17 ()Ljava/lang/String; public final fun component2 ()Ljava/lang/String; public final fun component3 ()Ldev/kord/common/entity/optional/Optional; public final fun component4 ()Ldev/kord/common/entity/optional/Optional; @@ -6002,11 +6003,12 @@ public final class dev/kord/common/entity/DiscordUser { public final fun component7 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component8 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component9 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;)Ldev/kord/common/entity/DiscordUser; - public static synthetic fun copy$default (Ldev/kord/common/entity/DiscordUser;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;ILjava/lang/Object;)Ldev/kord/common/entity/DiscordUser; + public final fun copy (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;)Ldev/kord/common/entity/DiscordUser; + public static synthetic fun copy$default (Ldev/kord/common/entity/DiscordUser;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;ILjava/lang/Object;)Ldev/kord/common/entity/DiscordUser; public fun equals (Ljava/lang/Object;)Z public final fun getAccentColor ()Ljava/lang/Integer; public final fun getAvatar ()Ljava/lang/String; + public final fun getAvatarDecoration ()Ljava/lang/String; public final fun getBanner ()Ljava/lang/String; public final fun getBot ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun getDiscriminator ()Ldev/kord/common/entity/optional/Optional; diff --git a/common/src/commonMain/kotlin/entity/DiscordUser.kt b/common/src/commonMain/kotlin/entity/DiscordUser.kt index 8b72099c347a..3c722dd80fe6 100644 --- a/common/src/commonMain/kotlin/entity/DiscordUser.kt +++ b/common/src/commonMain/kotlin/entity/DiscordUser.kt @@ -47,6 +47,9 @@ import kotlin.contracts.contract * @param flags The flags on a user's account. Unlike [publicFlags], these **are not** visible to other users. * @param premiumType The type of Nitro subscription on a user's account. * @param publicFlags The public flags on a user's account. Unlike [flags], these **are** visible ot other users. + * @param banner The user's banner hash. + * @param accentColor The user's banner color encoded as an integer representation of hexadecimal color code + * @param avatarDecoration The user;s avatar decoration hash. */ @Serializable public data class DiscordUser( @@ -75,7 +78,9 @@ public data class DiscordUser( val publicFlags: Optional = Optional.Missing(), val banner: String? = null, @SerialName("accent_color") - val accentColor: Int? = null + val accentColor: Int? = null, + @SerialName("avatar_decoration") + val avatarDecoration: String? = null ) /** From 1e2a2dcc20c2b17426e05647779ee99792908847 Mon Sep 17 00:00:00 2001 From: NoComment Date: Wed, 2 Aug 2023 16:04:30 +0100 Subject: [PATCH 2/4] Changes from review --- core/api/core.api | 15 ++++++++++----- core/src/commonMain/kotlin/cache/data/UserData.kt | 3 ++- core/src/commonMain/kotlin/entity/Asset.kt | 3 +++ core/src/commonMain/kotlin/entity/User.kt | 4 ++++ rest/api/rest.api | 1 + rest/src/commonMain/kotlin/route/DiscordCdn.kt | 3 +++ 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/core/api/core.api b/core/api/core.api index b68ed6467238..408ed4b3bc86 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -5456,10 +5456,11 @@ public final class dev/kord/core/cache/data/ThreadMetadataData$Companion { public final class dev/kord/core/cache/data/UserData { public static final field Companion Ldev/kord/core/cache/data/UserData$Companion; - public synthetic fun (ILdev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;)V - public synthetic fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (ILdev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;)V + public synthetic fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/common/entity/Snowflake; + public final fun component10 ()Ljava/lang/String; public final fun component2 ()Ljava/lang/String; public final fun component3 ()Ldev/kord/common/entity/optional/Optional; public final fun component4 ()Ldev/kord/common/entity/optional/Optional; @@ -5468,11 +5469,12 @@ public final class dev/kord/core/cache/data/UserData { public final fun component7 ()Ldev/kord/common/entity/optional/Optional; public final fun component8 ()Ljava/lang/String; public final fun component9 ()Ljava/lang/Integer; - public final fun copy (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;)Ldev/kord/core/cache/data/UserData; - public static synthetic fun copy$default (Ldev/kord/core/cache/data/UserData;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;ILjava/lang/Object;)Ldev/kord/core/cache/data/UserData; + public final fun copy (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;)Ldev/kord/core/cache/data/UserData; + public static synthetic fun copy$default (Ldev/kord/core/cache/data/UserData;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;ILjava/lang/Object;)Ldev/kord/core/cache/data/UserData; public fun equals (Ljava/lang/Object;)Z public final fun getAccentColor ()Ljava/lang/Integer; public final fun getAvatar ()Ljava/lang/String; + public final fun getAvatarDecoration ()Ljava/lang/String; public final fun getBanner ()Ljava/lang/String; public final fun getBot ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun getDiscriminator ()Ldev/kord/common/entity/optional/Optional; @@ -5794,6 +5796,7 @@ public final class dev/kord/core/entity/Asset$Companion { public final fun stickerPackBanner (Ldev/kord/common/entity/Snowflake;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset; public final fun teamIcon (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset; public final fun userAvatar (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset; + public final fun userAvatarDecoration (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset; public final fun userBanner (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset; } @@ -7195,6 +7198,8 @@ public class dev/kord/core/entity/User : dev/kord/core/behavior/UserBehavior { public final fun getAccentColor ()Ldev/kord/common/Color; public final fun getAvatar ()Ldev/kord/core/entity/Asset; public final synthetic fun getAvatar ()Ldev/kord/core/entity/Icon; + public final fun getAvatarDecoration ()Ldev/kord/core/entity/Asset; + public final fun getAvatarDecorationHash ()Ljava/lang/String; public final fun getAvatarHash ()Ljava/lang/String; public final fun getBanner ()Ldev/kord/core/entity/Asset; public final fun getBannerHash ()Ljava/lang/String; diff --git a/core/src/commonMain/kotlin/cache/data/UserData.kt b/core/src/commonMain/kotlin/cache/data/UserData.kt index b8cefb6613ce..a8570b30afa3 100644 --- a/core/src/commonMain/kotlin/cache/data/UserData.kt +++ b/core/src/commonMain/kotlin/cache/data/UserData.kt @@ -28,7 +28,8 @@ public data class UserData( val bot: OptionalBoolean = OptionalBoolean.Missing, val publicFlags: Optional = Optional.Missing(), val banner: String? = null, - val accentColor: Int? = null + val accentColor: Int? = null, + val avatarDecoration: String? = null ) { public companion object { diff --git a/core/src/commonMain/kotlin/entity/Asset.kt b/core/src/commonMain/kotlin/entity/Asset.kt index 0e3ef4ac8826..65c18d05d93f 100644 --- a/core/src/commonMain/kotlin/entity/Asset.kt +++ b/core/src/commonMain/kotlin/entity/Asset.kt @@ -67,6 +67,9 @@ public class Asset private constructor( public fun userAvatar(userId: Snowflake, hash: String, kord: Kord): Asset = Asset(hash.isAnimated, DiscordCdn.userAvatar(userId, hash), kord) + public fun userAvatarDecoration(userId: Snowflake, hash: String, kord: Kord): Asset = + Asset(hash.isAnimated, DiscordCdn.userAvatarDecoration(userId, hash), kord) + public fun memberAvatar(guildId: Snowflake, userId: Snowflake, hash: String, kord: Kord): Asset = Asset(hash.isAnimated, DiscordCdn.memberAvatar(guildId, userId, hash), kord) diff --git a/core/src/commonMain/kotlin/entity/User.kt b/core/src/commonMain/kotlin/entity/User.kt index 2283e9e72406..b217480a887b 100644 --- a/core/src/commonMain/kotlin/entity/User.kt +++ b/core/src/commonMain/kotlin/entity/User.kt @@ -63,6 +63,10 @@ public open class User( if (migratedToNewUsernameSystem) Asset.defaultUserAvatar(userId = id, kord) else @Suppress("DEPRECATION") Asset.defaultUserAvatar(discriminator.toInt(), kord) + public val avatarDecorationHash: String? get() = data.avatarDecoration + + public val avatarDecoration: Asset? get() = avatarDecorationHash?.let { Asset.userAvatarDecoration(data.id, it, kord) } + /** * The username of this user. */ diff --git a/rest/api/rest.api b/rest/api/rest.api index 3153bc532f19..4278c6405865 100644 --- a/rest/api/rest.api +++ b/rest/api/rest.api @@ -6219,6 +6219,7 @@ public final class dev/kord/rest/route/DiscordCdn { public final fun stickerPackBanner (Ldev/kord/common/entity/Snowflake;)Ldev/kord/rest/route/CdnUrl; public final fun teamIcon (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;)Ldev/kord/rest/route/CdnUrl; public final fun userAvatar (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;)Ldev/kord/rest/route/CdnUrl; + public final fun userAvatarDecoration (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;)Ldev/kord/rest/route/CdnUrl; public final fun userBanner (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;)Ldev/kord/rest/route/CdnUrl; } diff --git a/rest/src/commonMain/kotlin/route/DiscordCdn.kt b/rest/src/commonMain/kotlin/route/DiscordCdn.kt index 5011b505bea4..14ad6b323ea6 100644 --- a/rest/src/commonMain/kotlin/route/DiscordCdn.kt +++ b/rest/src/commonMain/kotlin/route/DiscordCdn.kt @@ -36,6 +36,9 @@ public object DiscordCdn { public fun memberAvatar(guildId: Snowflake, userId: Snowflake, hash: String): CdnUrl = CdnUrl("$BASE_URL/guilds/$guildId/users/$userId/avatars/$hash") + public fun userAvatarDecoration(userId: Snowflake, hash: String): CdnUrl = + CdnUrl("$BASE_URL/avatar-decorations/$userId/$hash") + public fun applicationIcon(applicationId: Snowflake, hash: String): CdnUrl = CdnUrl("$BASE_URL/app-icons/$applicationId/$hash") From 8b95bd7a28c8d03e4ebca84158dc96dc3b11e746 Mon Sep 17 00:00:00 2001 From: NoComment Date: Thu, 3 Aug 2023 10:25:24 +0100 Subject: [PATCH 3/4] Changes from review 2 --- common/api/common.api | 14 +++++++------- common/src/commonMain/kotlin/entity/DiscordUser.kt | 4 ++-- core/src/commonMain/kotlin/entity/Asset.kt | 7 ++++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/common/api/common.api b/common/api/common.api index e9081fa49947..e54084f97a04 100644 --- a/common/api/common.api +++ b/common/api/common.api @@ -5983,9 +5983,9 @@ public final class dev/kord/common/entity/DiscordUpdatedGuildMember$Companion { public final class dev/kord/common/entity/DiscordUser { public static final field Companion Ldev/kord/common/entity/DiscordUser$Companion; - public synthetic fun (ILdev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;)V - public synthetic fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (ILdev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Ldev/kord/common/entity/optional/Optional;)V + public synthetic fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;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/OptionalBoolean; public final fun component11 ()Ldev/kord/common/entity/optional/Optional; @@ -5994,7 +5994,7 @@ public final class dev/kord/common/entity/DiscordUser { public final fun component14 ()Ldev/kord/common/entity/optional/Optional; public final fun component15 ()Ljava/lang/String; public final fun component16 ()Ljava/lang/Integer; - public final fun component17 ()Ljava/lang/String; + public final fun component17 ()Ldev/kord/common/entity/optional/Optional; public final fun component2 ()Ljava/lang/String; public final fun component3 ()Ldev/kord/common/entity/optional/Optional; public final fun component4 ()Ldev/kord/common/entity/optional/Optional; @@ -6003,12 +6003,12 @@ public final class dev/kord/common/entity/DiscordUser { public final fun component7 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component8 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component9 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;)Ldev/kord/common/entity/DiscordUser; - public static synthetic fun copy$default (Ldev/kord/common/entity/DiscordUser;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;ILjava/lang/Object;)Ldev/kord/common/entity/DiscordUser; + public final fun copy (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/common/entity/DiscordUser; + public static synthetic fun copy$default (Ldev/kord/common/entity/DiscordUser;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;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;Ljava/lang/String;Ljava/lang/Integer;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/common/entity/DiscordUser; public fun equals (Ljava/lang/Object;)Z public final fun getAccentColor ()Ljava/lang/Integer; public final fun getAvatar ()Ljava/lang/String; - public final fun getAvatarDecoration ()Ljava/lang/String; + public final fun getAvatarDecoration ()Ldev/kord/common/entity/optional/Optional; public final fun getBanner ()Ljava/lang/String; public final fun getBot ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun getDiscriminator ()Ldev/kord/common/entity/optional/Optional; diff --git a/common/src/commonMain/kotlin/entity/DiscordUser.kt b/common/src/commonMain/kotlin/entity/DiscordUser.kt index 3c722dd80fe6..e8c8e679204e 100644 --- a/common/src/commonMain/kotlin/entity/DiscordUser.kt +++ b/common/src/commonMain/kotlin/entity/DiscordUser.kt @@ -49,7 +49,7 @@ import kotlin.contracts.contract * @param publicFlags The public flags on a user's account. Unlike [flags], these **are** visible ot other users. * @param banner The user's banner hash. * @param accentColor The user's banner color encoded as an integer representation of hexadecimal color code - * @param avatarDecoration The user;s avatar decoration hash. + * @param avatarDecoration The user's avatar decoration hash. */ @Serializable public data class DiscordUser( @@ -80,7 +80,7 @@ public data class DiscordUser( @SerialName("accent_color") val accentColor: Int? = null, @SerialName("avatar_decoration") - val avatarDecoration: String? = null + val avatarDecoration: Optional = Optional.Missing(), ) /** diff --git a/core/src/commonMain/kotlin/entity/Asset.kt b/core/src/commonMain/kotlin/entity/Asset.kt index 65c18d05d93f..c02d38e1c554 100644 --- a/core/src/commonMain/kotlin/entity/Asset.kt +++ b/core/src/commonMain/kotlin/entity/Asset.kt @@ -67,12 +67,13 @@ public class Asset private constructor( public fun userAvatar(userId: Snowflake, hash: String, kord: Kord): Asset = Asset(hash.isAnimated, DiscordCdn.userAvatar(userId, hash), kord) - public fun userAvatarDecoration(userId: Snowflake, hash: String, kord: Kord): Asset = - Asset(hash.isAnimated, DiscordCdn.userAvatarDecoration(userId, hash), kord) - public fun memberAvatar(guildId: Snowflake, userId: Snowflake, hash: String, kord: Kord): Asset = Asset(hash.isAnimated, DiscordCdn.memberAvatar(guildId, userId, hash), kord) + // https://github.com/discord/discord-api-docs/pull/5723#issuecomment-1342674515 + public fun userAvatarDecoration(userId: Snowflake, hash: String, kord: Kord): Asset = + Asset(hash.isAnimated, DiscordCdn.userAvatarDecoration(userId, hash), kord, recommendedFormat = PNG) + public fun applicationIcon(applicationId: Snowflake, hash: String, kord: Kord): Asset = Asset(isAnimated = false, DiscordCdn.applicationIcon(applicationId, hash), kord) From c64f5ba18b4e318a7fd2f6882016d86b2f576a24 Mon Sep 17 00:00:00 2001 From: NoComment Date: Thu, 3 Aug 2023 15:36:11 +0100 Subject: [PATCH 4/4] Changes from review 3 --- core/api/core.api | 14 +++++++------- core/src/commonMain/kotlin/cache/data/UserData.kt | 4 ++-- core/src/commonMain/kotlin/entity/User.kt | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/api/core.api b/core/api/core.api index 408ed4b3bc86..d1d2189f57f5 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -5456,11 +5456,11 @@ public final class dev/kord/core/cache/data/ThreadMetadataData$Companion { public final class dev/kord/core/cache/data/UserData { public static final field Companion Ldev/kord/core/cache/data/UserData$Companion; - public synthetic fun (ILdev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;)V - public synthetic fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (ILdev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ldev/kord/common/entity/optional/Optional;)V + public synthetic fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/common/entity/Snowflake; - public final fun component10 ()Ljava/lang/String; + public final fun component10 ()Ldev/kord/common/entity/optional/Optional; public final fun component2 ()Ljava/lang/String; public final fun component3 ()Ldev/kord/common/entity/optional/Optional; public final fun component4 ()Ldev/kord/common/entity/optional/Optional; @@ -5469,12 +5469,12 @@ public final class dev/kord/core/cache/data/UserData { public final fun component7 ()Ldev/kord/common/entity/optional/Optional; public final fun component8 ()Ljava/lang/String; public final fun component9 ()Ljava/lang/Integer; - public final fun copy (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;)Ldev/kord/core/cache/data/UserData; - public static synthetic fun copy$default (Ldev/kord/core/cache/data/UserData;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;ILjava/lang/Object;)Ldev/kord/core/cache/data/UserData; + public final fun copy (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/core/cache/data/UserData; + public static synthetic fun copy$default (Ldev/kord/core/cache/data/UserData;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ljava/lang/Integer;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/core/cache/data/UserData; public fun equals (Ljava/lang/Object;)Z public final fun getAccentColor ()Ljava/lang/Integer; public final fun getAvatar ()Ljava/lang/String; - public final fun getAvatarDecoration ()Ljava/lang/String; + public final fun getAvatarDecoration ()Ldev/kord/common/entity/optional/Optional; public final fun getBanner ()Ljava/lang/String; public final fun getBot ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun getDiscriminator ()Ldev/kord/common/entity/optional/Optional; diff --git a/core/src/commonMain/kotlin/cache/data/UserData.kt b/core/src/commonMain/kotlin/cache/data/UserData.kt index a8570b30afa3..cb5bce576941 100644 --- a/core/src/commonMain/kotlin/cache/data/UserData.kt +++ b/core/src/commonMain/kotlin/cache/data/UserData.kt @@ -29,7 +29,7 @@ public data class UserData( val publicFlags: Optional = Optional.Missing(), val banner: String? = null, val accentColor: Int? = null, - val avatarDecoration: String? = null + val avatarDecoration: Optional = Optional.Missing() ) { public companion object { @@ -41,7 +41,7 @@ public data class UserData( } public fun from(entity: DiscordUser): UserData = with(entity) { - UserData(id, username, @Suppress("DEPRECATION") discriminator, globalName, avatar, bot, publicFlags, banner, accentColor) + UserData(id, username, @Suppress("DEPRECATION") discriminator, globalName, avatar, bot, publicFlags, banner, accentColor, avatarDecoration) } public fun from(entity: DiscordOptionallyMemberUser): UserData = with(entity) { diff --git a/core/src/commonMain/kotlin/entity/User.kt b/core/src/commonMain/kotlin/entity/User.kt index b217480a887b..5c5f0a7adce8 100644 --- a/core/src/commonMain/kotlin/entity/User.kt +++ b/core/src/commonMain/kotlin/entity/User.kt @@ -63,7 +63,7 @@ public open class User( if (migratedToNewUsernameSystem) Asset.defaultUserAvatar(userId = id, kord) else @Suppress("DEPRECATION") Asset.defaultUserAvatar(discriminator.toInt(), kord) - public val avatarDecorationHash: String? get() = data.avatarDecoration + public val avatarDecorationHash: String? get() = data.avatarDecoration.value public val avatarDecoration: Asset? get() = avatarDecorationHash?.let { Asset.userAvatarDecoration(data.id, it, kord) }