diff --git a/common/api/common.api b/common/api/common.api index 3f143644ac39..98c6e53cc2de 100644 --- a/common/api/common.api +++ b/common/api/common.api @@ -5985,9 +5985,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;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; @@ -5996,6 +5996,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 ()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; @@ -6004,11 +6005,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;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 ()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 8b72099c347a..e8c8e679204e 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: Optional = Optional.Missing(), ) /** diff --git a/core/api/core.api b/core/api/core.api index 736f8ca11f38..983cc33c83a8 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -5458,10 +5458,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;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 ()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; @@ -5470,11 +5471,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;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 ()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; @@ -5796,6 +5798,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; } @@ -7197,6 +7200,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..cb5bce576941 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: Optional = Optional.Missing() ) { public companion object { @@ -40,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/Asset.kt b/core/src/commonMain/kotlin/entity/Asset.kt index 0e3ef4ac8826..c02d38e1c554 100644 --- a/core/src/commonMain/kotlin/entity/Asset.kt +++ b/core/src/commonMain/kotlin/entity/Asset.kt @@ -70,6 +70,10 @@ public class Asset private constructor( 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) diff --git a/core/src/commonMain/kotlin/entity/User.kt b/core/src/commonMain/kotlin/entity/User.kt index 2283e9e72406..5c5f0a7adce8 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.value + + 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")