Skip to content

Commit

Permalink
Replace Icon with Asset (#703)
Browse files Browse the repository at this point in the history
This introduces the new dev.kord.core.entity.Asset class that is a
replacement for dev.kord.core.entity.Icon with coverage of more CDN
endpoints and fewer inconsistencies (e.g. format was not considered when
calling Icon.getImage() with no parameters).

Properties with type Icon are now also deprecated and are replaced with
similar properties with type Asset. This means there are a few source-
(but not binary-) incompatible changes:

 * The types of dev.kord.core.entity.GuildEmoji.image,
   dev.kord.core.entity.Member.memberAvatar,
   dev.kord.core.entity.Role.icon, dev.kord.core.entity.User.avatar and
   dev.kord.core.entity.User.defaultAvatar were changed from Icon to
   Asset.

 * The type of dev.kord.core.entity.Team.icon was changed from String to
   Asset. Team.iconHash provides the previous functionality.

---------

Co-authored-by: Lukellmann <[email protected]>
  • Loading branch information
Luis and lukellmann authored Apr 12, 2023
1 parent d3b1312 commit 8c77dd9
Show file tree
Hide file tree
Showing 17 changed files with 335 additions and 18 deletions.
69 changes: 63 additions & 6 deletions core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -5771,6 +5771,36 @@ public final class dev/kord/core/entity/Application : dev/kord/core/entity/BaseA
public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/Strategizable;
}

public final class dev/kord/core/entity/Asset : dev/kord/core/KordObject {
public static final field Companion Ldev/kord/core/entity/Asset$Companion;
public synthetic fun <init> (ZLdev/kord/rest/route/CdnUrl;Ldev/kord/core/Kord;Ldev/kord/rest/Image$Format;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getCdnUrl ()Ldev/kord/rest/route/CdnUrl;
public final fun getImage (Ldev/kord/rest/Image$Format;Ldev/kord/rest/Image$Size;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun getImage$default (Ldev/kord/core/entity/Asset;Ldev/kord/rest/Image$Format;Ldev/kord/rest/Image$Size;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public fun getKord ()Ldev/kord/core/Kord;
public final fun isAnimated ()Z
}

public final class dev/kord/core/entity/Asset$Companion {
public final fun applicationCover (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset;
public final fun applicationIcon (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset;
public final fun defaultUserAvatar (ILdev/kord/core/Kord;)Ldev/kord/core/entity/Asset;
public final fun emoji (Ldev/kord/common/entity/Snowflake;ZLdev/kord/core/Kord;)Ldev/kord/core/entity/Asset;
public final fun guildBanner (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset;
public final fun guildDiscoverySplash (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset;
public final fun guildIcon (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset;
public final fun guildScheduledEventCover (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset;
public final fun guildSplash (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset;
public final fun memberAvatar (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset;
public final fun memberBanner (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset;
public final fun roleIcon (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset;
public final fun sticker (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/MessageStickerType;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset;
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 userBanner (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/core/Kord;)Ldev/kord/core/entity/Asset;
}

public final class dev/kord/core/entity/Attachment : dev/kord/core/entity/KordEntity {
public fun <init> (Ldev/kord/core/cache/data/AttachmentData;Ldev/kord/core/Kord;)V
public fun compareTo (Ldev/kord/core/entity/Entity;)I
Expand Down Expand Up @@ -5852,6 +5882,7 @@ public abstract class dev/kord/core/entity/BaseApplication : dev/kord/core/entit
public fun compareTo (Ldev/kord/core/entity/Entity;)I
public synthetic fun compareTo (Ljava/lang/Object;)I
public final fun equals (Ljava/lang/Object;)Z
public final fun getCoverImage ()Ldev/kord/core/entity/Asset;
public final fun getCoverImageHash ()Ljava/lang/String;
public final fun getCustomInstallUrl ()Ljava/lang/String;
public abstract fun getData ()Ldev/kord/core/cache/data/BaseApplicationData;
Expand All @@ -5860,6 +5891,7 @@ public abstract class dev/kord/core/entity/BaseApplication : dev/kord/core/entit
public final fun getGuild ()Ldev/kord/core/behavior/GuildBehavior;
public final fun getGuildId ()Ldev/kord/common/entity/Snowflake;
public final fun getGuildOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getIcon ()Ldev/kord/core/entity/Asset;
public final fun getIconHash ()Ljava/lang/String;
public final fun getId ()Ldev/kord/common/entity/Snowflake;
public final fun getInstallParams ()Ldev/kord/common/entity/InstallParams;
Expand Down Expand Up @@ -6097,6 +6129,7 @@ public final class dev/kord/core/entity/Guild : dev/kord/core/behavior/GuildBeha
public fun getAutoModerationRules ()Lkotlinx/coroutines/flow/Flow;
public fun getBan (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun getBanOrNull (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getBanner ()Ldev/kord/core/entity/Asset;
public final fun getBanner (Ldev/kord/rest/Image$Format;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getBannerHash ()Ljava/lang/String;
public final fun getBannerUrl (Ldev/kord/rest/Image$Format;)Ljava/lang/String;
Expand All @@ -6111,6 +6144,7 @@ public final class dev/kord/core/entity/Guild : dev/kord/core/behavior/GuildBeha
public final fun getData ()Ldev/kord/core/cache/data/GuildData;
public final fun getDefaultMessageNotificationLevel ()Ldev/kord/common/entity/DefaultMessageNotificationLevel;
public final fun getDescription ()Ljava/lang/String;
public final fun getDiscoverySplash ()Ldev/kord/core/entity/Asset;
public final fun getDiscoverySplash (Ldev/kord/rest/Image$Format;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getDiscoverySplashHash ()Ljava/lang/String;
public final fun getDiscoverySplashUrl (Ldev/kord/rest/Image$Format;)Ljava/lang/String;
Expand All @@ -6126,6 +6160,7 @@ public final class dev/kord/core/entity/Guild : dev/kord/core/behavior/GuildBeha
public fun getGateway ()Ldev/kord/gateway/Gateway;
public fun getGuildScheduledEvent (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun getGuildScheduledEventOrNull (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getIcon ()Ldev/kord/core/entity/Asset;
public final fun getIcon (Ldev/kord/rest/Image$Format;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getIconHash ()Ljava/lang/String;
public final fun getIconUrl (Ldev/kord/rest/Image$Format;)Ljava/lang/String;
Expand Down Expand Up @@ -6177,6 +6212,7 @@ public final class dev/kord/core/entity/Guild : dev/kord/core/behavior/GuildBeha
public final fun getRulesChannel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getRulesChannelId ()Ldev/kord/common/entity/Snowflake;
public fun getScheduledEvents ()Lkotlinx/coroutines/flow/Flow;
public final fun getSplash ()Ldev/kord/core/entity/Asset;
public final fun getSplash (Ldev/kord/rest/Image$Format;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getSplashHash ()Ljava/lang/String;
public final fun getSplashUrl (Ldev/kord/rest/Image$Format;)Ljava/lang/String;
Expand Down Expand Up @@ -6233,7 +6269,8 @@ public final class dev/kord/core/entity/GuildEmoji : dev/kord/core/entity/Emoji,
public final fun getData ()Ldev/kord/core/cache/data/EmojiData;
public final fun getGuildId ()Ldev/kord/common/entity/Snowflake;
public fun getId ()Ldev/kord/common/entity/Snowflake;
public final fun getImage ()Ldev/kord/core/entity/Icon;
public final fun getImage ()Ldev/kord/core/entity/Asset;
public final synthetic fun getImage ()Ldev/kord/core/entity/Icon;
public fun getKord ()Ldev/kord/core/Kord;
public final fun getMember ()Ldev/kord/core/behavior/MemberBehavior;
public final fun getMember (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down Expand Up @@ -6364,6 +6401,7 @@ public final class dev/kord/core/entity/GuildScheduledEvent : dev/kord/core/beha
public fun getGuildId ()Ldev/kord/common/entity/Snowflake;
public final fun getGuildOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun getId ()Ldev/kord/common/entity/Snowflake;
public final fun getImage ()Ldev/kord/core/entity/Asset;
public final fun getImageHash ()Ljava/lang/String;
public fun getKord ()Ldev/kord/core/Kord;
public fun getMembers ()Lkotlinx/coroutines/flow/Flow;
Expand Down Expand Up @@ -6564,7 +6602,9 @@ public final class dev/kord/core/entity/Member : dev/kord/core/entity/User, dev/
public fun getGuildId ()Ldev/kord/common/entity/Snowflake;
public fun getGuildOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getJoinedAt ()Lkotlinx/datetime/Instant;
public final fun getMemberAvatar ()Ldev/kord/core/entity/Icon;
public final fun getMemberAvatar ()Ldev/kord/core/entity/Asset;
public final synthetic fun getMemberAvatar ()Ldev/kord/core/entity/Icon;
public final fun getMemberAvatarHash ()Ljava/lang/String;
public final fun getMemberData ()Ldev/kord/core/cache/data/MemberData;
public final fun getNickname ()Ljava/lang/String;
public final fun getPermissions (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down Expand Up @@ -6722,7 +6762,9 @@ public final class dev/kord/core/entity/PartialGuild : dev/kord/core/behavior/Gu
public fun getAutoModerationRules ()Lkotlinx/coroutines/flow/Flow;
public fun getBan (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun getBanOrNull (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getBanner ()Ldev/kord/core/entity/Asset;
public final fun getBanner (Ldev/kord/rest/Image$Format;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getBannerHash ()Ljava/lang/String;
public final fun getBannerUrl (Ldev/kord/rest/Image$Format;)Ljava/lang/String;
public fun getBans ()Lkotlinx/coroutines/flow/Flow;
public fun getCachedThreads ()Lkotlinx/coroutines/flow/Flow;
Expand All @@ -6739,6 +6781,7 @@ public final class dev/kord/core/entity/PartialGuild : dev/kord/core/behavior/Gu
public final fun getGuildOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun getGuildScheduledEvent (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun getGuildScheduledEventOrNull (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getIcon ()Ldev/kord/core/entity/Asset;
public final fun getIcon (Ldev/kord/rest/Image$Format;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getIconHash ()Ljava/lang/String;
public final fun getIconUrl (Ldev/kord/rest/Image$Format;)Ljava/lang/String;
Expand Down Expand Up @@ -6767,6 +6810,7 @@ public final class dev/kord/core/entity/PartialGuild : dev/kord/core/behavior/Gu
public fun getRoleOrNull (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun getRoles ()Lkotlinx/coroutines/flow/Flow;
public fun getScheduledEvents ()Lkotlinx/coroutines/flow/Flow;
public final fun getSplash ()Ldev/kord/core/entity/Asset;
public final fun getSplashHash ()Ljava/lang/String;
public fun getSticker (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun getStickerOrNull (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down Expand Up @@ -6948,7 +6992,9 @@ public final class dev/kord/core/entity/Role : dev/kord/core/behavior/RoleBehavi
public fun getGuild ()Ldev/kord/core/behavior/GuildBehavior;
public fun getGuildId ()Ldev/kord/common/entity/Snowflake;
public final fun getHoisted ()Z
public final fun getIcon ()Ldev/kord/core/entity/Icon;
public final fun getIcon ()Ldev/kord/core/entity/Asset;
public final synthetic fun getIcon ()Ldev/kord/core/entity/Icon;
public final fun getIconHash ()Ljava/lang/String;
public fun getId ()Ldev/kord/common/entity/Snowflake;
public fun getKord ()Ldev/kord/core/Kord;
public final fun getManaged ()Z
Expand Down Expand Up @@ -7026,6 +7072,7 @@ public class dev/kord/core/entity/Sticker : dev/kord/core/entity/KordEntity {
public fun <init> (Ldev/kord/core/cache/data/StickerData;Ldev/kord/core/Kord;)V
public fun compareTo (Ldev/kord/core/entity/Entity;)I
public synthetic fun compareTo (Ljava/lang/Object;)I
public final fun getAsset ()Ldev/kord/core/entity/Asset;
public final fun getAvailable ()Z
public final fun getData ()Ldev/kord/core/cache/data/StickerData;
public final fun getDescription ()Ljava/lang/String;
Expand All @@ -7044,6 +7091,7 @@ public final class dev/kord/core/entity/StickerItem : dev/kord/core/entity/KordE
public synthetic fun <init> (Ldev/kord/core/cache/data/StickerItemData;Ldev/kord/core/Kord;Ldev/kord/core/supplier/EntitySupplier;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun compareTo (Ldev/kord/core/entity/Entity;)I
public synthetic fun compareTo (Ljava/lang/Object;)I
public final fun getAsset ()Ldev/kord/core/entity/Asset;
public final fun getData ()Ldev/kord/core/cache/data/StickerItemData;
public final fun getFormatType ()Ldev/kord/common/entity/MessageStickerType;
public fun getId ()Ldev/kord/common/entity/Snowflake;
Expand All @@ -7059,6 +7107,8 @@ public final class dev/kord/core/entity/StickerPack : dev/kord/core/entity/KordE
public fun <init> (Ldev/kord/core/cache/data/StickerPackData;Ldev/kord/core/Kord;)V
public fun compareTo (Ldev/kord/core/entity/Entity;)I
public synthetic fun compareTo (Ljava/lang/Object;)I
public final fun getBanner ()Ldev/kord/core/entity/Asset;
public final fun getBannerId ()Ldev/kord/common/entity/Snowflake;
public final fun getCoverStickerId ()Ldev/kord/common/entity/Snowflake;
public final fun getData ()Ldev/kord/core/cache/data/StickerPackData;
public final fun getDescription ()Ljava/lang/String;
Expand All @@ -7080,7 +7130,9 @@ public final class dev/kord/core/entity/Team : dev/kord/core/entity/KordEntity,
public fun compareTo (Ldev/kord/core/entity/Entity;)I
public synthetic fun compareTo (Ljava/lang/Object;)I
public final fun getData ()Ldev/kord/core/cache/data/TeamData;
public final fun getIcon ()Ljava/lang/String;
public final fun getIcon ()Ldev/kord/core/entity/Asset;
public final synthetic fun getIcon ()Ljava/lang/String;
public final fun getIconHash ()Ljava/lang/String;
public fun getId ()Ldev/kord/common/entity/Snowflake;
public fun getKord ()Ldev/kord/core/Kord;
public final fun getMembers ()Ljava/util/List;
Expand Down Expand Up @@ -7139,10 +7191,15 @@ public class dev/kord/core/entity/User : dev/kord/core/behavior/UserBehavior {
public fun fetchUser (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun fetchUserOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getAccentColor ()Ldev/kord/common/Color;
public final fun getAvatar ()Ldev/kord/core/entity/Icon;
public final fun getAvatar ()Ldev/kord/core/entity/Asset;
public final synthetic fun getAvatar ()Ldev/kord/core/entity/Icon;
public final fun getAvatarHash ()Ljava/lang/String;
public final fun getBanner ()Ldev/kord/core/entity/Asset;
public final fun getBannerHash ()Ljava/lang/String;
public final fun getBannerUrl (Ldev/kord/rest/Image$Format;)Ljava/lang/String;
public final fun getData ()Ldev/kord/core/cache/data/UserData;
public final fun getDefaultAvatar ()Ldev/kord/core/entity/Icon;
public final fun getDefaultAvatar ()Ldev/kord/core/entity/Asset;
public final synthetic fun getDefaultAvatar ()Ldev/kord/core/entity/Icon;
public final fun getDiscriminator ()Ljava/lang/String;
public fun getDmChannel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun getDmChannelOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down
4 changes: 4 additions & 0 deletions core/src/commonMain/kotlin/entity/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public sealed class BaseApplication(

public val name: String get() = data.name

public val icon: Asset? get() = iconHash?.let { Asset.applicationIcon(id, it, kord) }

public val iconHash: String? get() = data.icon

public val description: String get() = data.description
Expand Down Expand Up @@ -52,6 +54,8 @@ public sealed class BaseApplication(

public val slug: String? get() = data.slug.value

public val coverImage: Asset? get() = coverImageHash?.let { Asset.applicationCover(id, it, kord) }

public val coverImageHash: String? get() = data.coverImage.value

public val flags: ApplicationFlags? get() = data.flags.value
Expand Down
Loading

0 comments on commit 8c77dd9

Please sign in to comment.