From c87d748e7bdfbb0b6771ba3c39e80b7100b8bfad Mon Sep 17 00:00:00 2001 From: Luca Kellermann Date: Thu, 12 Sep 2024 03:53:06 +0200 Subject: [PATCH] feat(core): subscriptions --- core/api/core.api | 158 +++++++++++++++- core/api/core.klib.api | 172 +++++++++++++++++- core/src/commonMain/kotlin/Kord.kt | 58 +----- core/src/commonMain/kotlin/Unsafe.kt | 5 + .../behavior/monetization/SkuBehavior.kt | 122 +++++++++++++ .../kotlin/cache/DataCacheExtensions.kt | 2 + core/src/commonMain/kotlin/cache/KordCache.kt | 4 + .../kotlin/cache/data/SubscriptionData.kt | 41 +++++ .../commonMain/kotlin/cache/data/UserData.kt | 1 + .../kotlin/entity/monetization/Sku.kt | 16 +- .../entity/monetization/Subscription.kt | 65 +++++++ .../event/monetization/SubscriptionEvents.kt | 52 ++++++ .../exception/EntityNotFoundException.kt | 3 + .../handler/DefaultGatewayEventInterceptor.kt | 1 + .../handler/SubscriptionEventHandler.kt | 68 +++++++ .../kotlin/supplier/CacheEntitySupplier.kt | 30 +++ .../kotlin/supplier/EntitySupplier.kt | 28 +++ .../kotlin/supplier/FallbackEntitySupplier.kt | 8 + .../kotlin/supplier/RestEntitySupplier.kt | 26 +++ .../kotlin/supplier/StoreEntitySupplier.kt | 8 + 20 files changed, 794 insertions(+), 74 deletions(-) create mode 100644 core/src/commonMain/kotlin/behavior/monetization/SkuBehavior.kt create mode 100644 core/src/commonMain/kotlin/cache/data/SubscriptionData.kt create mode 100644 core/src/commonMain/kotlin/entity/monetization/Subscription.kt create mode 100644 core/src/commonMain/kotlin/event/monetization/SubscriptionEvents.kt create mode 100644 core/src/commonMain/kotlin/gateway/handler/SubscriptionEventHandler.kt diff --git a/core/api/core.api b/core/api/core.api index d5d8a80e32f..a8fec6f643c 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -27,9 +27,6 @@ public final class dev/kord/core/Kord : kotlinx/coroutines/CoroutineScope { public static synthetic fun createGuildMessageCommand$default (Ldev/kord/core/Kord;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public final fun createGuildUserCommand (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun createGuildUserCommand$default (Ldev/kord/core/Kord;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; - public final fun createTestEntitlement (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/EntitlementOwnerType;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun createTestEntitlement (Ldev/kord/common/entity/Snowflake;Ldev/kord/core/behavior/GuildBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun createTestEntitlement (Ldev/kord/common/entity/Snowflake;Ldev/kord/core/behavior/UserBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun editPresence (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun editSelf (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun equals (Ljava/lang/Object;)Z @@ -144,6 +141,8 @@ public final class dev/kord/core/Unsafe { public final fun privateThreadParent (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/behavior/channel/threads/PrivateThreadParentChannelBehavior; public final fun publicThreadParent (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/behavior/channel/threads/ThreadParentChannelBehavior; public final fun role (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/behavior/RoleBehavior; + public final fun sku (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/behavior/monetization/SkuBehavior; + public static synthetic fun sku$default (Ldev/kord/core/Unsafe;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;ILjava/lang/Object;)Ldev/kord/core/behavior/monetization/SkuBehavior; public final fun spamAutoModerationRule (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/behavior/automoderation/SpamAutoModerationRuleBehavior; public final fun stageInstance (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/behavior/StageInstanceBehavior; public final fun textChannel (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ldev/kord/core/behavior/channel/TextChannelBehavior; @@ -2129,6 +2128,29 @@ public final class dev/kord/core/behavior/interaction/response/PublicMessageInte public static fun withStrategy (Ldev/kord/core/behavior/interaction/response/PublicMessageInteractionResponseBehavior;Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/interaction/response/PublicMessageInteractionResponseBehavior; } +public abstract interface class dev/kord/core/behavior/monetization/SkuBehavior : dev/kord/core/entity/KordEntity, dev/kord/core/entity/Strategizable { + public abstract fun createTestEntitlement (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/EntitlementOwnerType;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun createTestEntitlement (Ldev/kord/common/entity/Snowflake;Ldev/kord/core/behavior/GuildBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun createTestEntitlement (Ldev/kord/common/entity/Snowflake;Ldev/kord/core/behavior/UserBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun getApplicationId ()Ldev/kord/common/entity/Snowflake; + public abstract fun getSubscription (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun getSubscriptionOrNull (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/monetization/SkuBehavior; +} + +public final class dev/kord/core/behavior/monetization/SkuBehavior$DefaultImpls { + public static fun compareTo (Ldev/kord/core/behavior/monetization/SkuBehavior;Ldev/kord/core/entity/Entity;)I + public static fun createTestEntitlement (Ldev/kord/core/behavior/monetization/SkuBehavior;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/EntitlementOwnerType;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun createTestEntitlement (Ldev/kord/core/behavior/monetization/SkuBehavior;Ldev/kord/common/entity/Snowflake;Ldev/kord/core/behavior/GuildBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun createTestEntitlement (Ldev/kord/core/behavior/monetization/SkuBehavior;Ldev/kord/common/entity/Snowflake;Ldev/kord/core/behavior/UserBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getSubscription (Ldev/kord/core/behavior/monetization/SkuBehavior;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getSubscriptionOrNull (Ldev/kord/core/behavior/monetization/SkuBehavior;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/kord/core/behavior/monetization/SkuBehaviorKt { + public static final fun getSubscriptions (Ldev/kord/core/behavior/monetization/SkuBehavior;Lkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/flow/Flow; +} + public final class dev/kord/core/builder/components/ButtonBuilderExtensionsKt { public static final fun emoji (Ldev/kord/rest/builder/component/ButtonBuilder;Ldev/kord/core/entity/GuildEmoji;)V public static final fun emoji (Ldev/kord/rest/builder/component/ButtonBuilder;Ldev/kord/core/entity/ReactionEmoji$Custom;)V @@ -2243,6 +2265,7 @@ public final class dev/kord/core/cache/KordCacheBuilder { public final fun roles (Lkotlin/jvm/functions/Function2;)V public final fun setDefaultGenerator (Lkotlin/jvm/functions/Function2;)V public final fun stickers (Lkotlin/jvm/functions/Function2;)V + public final fun subscriptions (Lkotlin/jvm/functions/Function2;)V public final fun users (Lkotlin/jvm/functions/Function2;)V public final fun voiceState (Lkotlin/jvm/functions/Function2;)V public final fun webhooks (Lkotlin/jvm/functions/Function2;)V @@ -5173,6 +5196,52 @@ public final class dev/kord/core/cache/data/StickerPackData$Companion { public final fun getDescription ()Ldev/kord/cache/api/data/DataDescription; } +public final class dev/kord/core/cache/data/SubscriptionData { + public static final field Companion Ldev/kord/core/cache/data/SubscriptionData$Companion; + public fun (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ljava/util/List;Ljava/util/List;Lkotlinx/datetime/Instant;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/SubscriptionStatus;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/optional/Optional;)V + public synthetic fun (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ljava/util/List;Ljava/util/List;Lkotlinx/datetime/Instant;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/SubscriptionStatus;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ldev/kord/common/entity/Snowflake; + public final fun component2 ()Ldev/kord/common/entity/Snowflake; + public final fun component3 ()Ljava/util/List; + public final fun component4 ()Ljava/util/List; + public final fun component5 ()Lkotlinx/datetime/Instant; + public final fun component6 ()Lkotlinx/datetime/Instant; + public final fun component7 ()Ldev/kord/common/entity/SubscriptionStatus; + public final fun component8 ()Lkotlinx/datetime/Instant; + public final fun component9 ()Ldev/kord/common/entity/optional/Optional; + public final fun copy (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ljava/util/List;Ljava/util/List;Lkotlinx/datetime/Instant;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/SubscriptionStatus;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/core/cache/data/SubscriptionData; + public static synthetic fun copy$default (Ldev/kord/core/cache/data/SubscriptionData;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ljava/util/List;Ljava/util/List;Lkotlinx/datetime/Instant;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/SubscriptionStatus;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/core/cache/data/SubscriptionData; + public fun equals (Ljava/lang/Object;)Z + public final fun getCanceledAt ()Lkotlinx/datetime/Instant; + public final fun getCountry ()Ldev/kord/common/entity/optional/Optional; + public final fun getCurrentPeriodEnd ()Lkotlinx/datetime/Instant; + public final fun getCurrentPeriodStart ()Lkotlinx/datetime/Instant; + public final fun getEntitlementIds ()Ljava/util/List; + public final fun getId ()Ldev/kord/common/entity/Snowflake; + public final fun getSkuIds ()Ljava/util/List; + public final fun getStatus ()Ldev/kord/common/entity/SubscriptionStatus; + public final fun getUserId ()Ldev/kord/common/entity/Snowflake; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public synthetic class dev/kord/core/cache/data/SubscriptionData$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/kord/core/cache/data/SubscriptionData$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/kord/core/cache/data/SubscriptionData; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/kord/core/cache/data/SubscriptionData;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/kord/core/cache/data/SubscriptionData$Companion { + public final fun from (Ldev/kord/common/entity/DiscordSubscription;)Ldev/kord/core/cache/data/SubscriptionData; + public final fun getDescription ()Ldev/kord/cache/api/data/DataDescription; + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/kord/core/cache/data/TeamData { public static final field Companion Ldev/kord/core/cache/data/TeamData$Companion; public fun (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ljava/util/List;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;)V @@ -10849,21 +10918,53 @@ public final class dev/kord/core/entity/monetization/Entitlement : dev/kord/core public fun toString ()Ljava/lang/String; } -public final class dev/kord/core/entity/monetization/Sku : dev/kord/core/entity/KordEntity { - public fun (Ldev/kord/common/entity/DiscordSku;Ldev/kord/core/Kord;)V +public final class dev/kord/core/entity/monetization/Sku : dev/kord/core/behavior/monetization/SkuBehavior { + public fun (Ldev/kord/common/entity/DiscordSku;Ldev/kord/core/Kord;Ldev/kord/core/supplier/EntitySupplier;)V + public synthetic fun (Ldev/kord/common/entity/DiscordSku;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 fun createTestEntitlement (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/EntitlementOwnerType;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun createTestEntitlement (Ldev/kord/common/entity/Snowflake;Ldev/kord/core/behavior/GuildBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun createTestEntitlement (Ldev/kord/common/entity/Snowflake;Ldev/kord/core/behavior/UserBehavior;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun equals (Ljava/lang/Object;)Z - public final fun getApplicationId ()Ldev/kord/common/entity/Snowflake; + public fun getApplicationId ()Ldev/kord/common/entity/Snowflake; public final fun getData ()Ldev/kord/common/entity/DiscordSku; public final fun getFlags ()Ldev/kord/common/entity/SkuFlags; public fun getId ()Ldev/kord/common/entity/Snowflake; public fun getKord ()Ldev/kord/core/Kord; public final fun getName ()Ljava/lang/String; public final fun getSlug ()Ljava/lang/String; + public fun getSubscription (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun getSubscriptionOrNull (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun getSupplier ()Ldev/kord/core/supplier/EntitySupplier; public final fun getType ()Ldev/kord/common/entity/SkuType; public fun hashCode ()I public fun toString ()Ljava/lang/String; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/behavior/monetization/SkuBehavior; + public synthetic fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/Strategizable; + public fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/monetization/Sku; +} + +public final class dev/kord/core/entity/monetization/Subscription : dev/kord/core/entity/KordEntity { + public fun (Ldev/kord/core/cache/data/SubscriptionData;Ldev/kord/core/Kord;)V + public fun compareTo (Ldev/kord/core/entity/Entity;)I + public synthetic fun compareTo (Ljava/lang/Object;)I + public fun equals (Ljava/lang/Object;)Z + public final fun getCanceledAt ()Lkotlinx/datetime/Instant; + public final fun getCountry ()Ljava/lang/String; + public final fun getCurrentPeriodEnd ()Lkotlinx/datetime/Instant; + public final fun getCurrentPeriodStart ()Lkotlinx/datetime/Instant; + public final fun getData ()Ldev/kord/core/cache/data/SubscriptionData; + public final fun getEntitlementIds ()Ljava/util/List; + public fun getId ()Ldev/kord/common/entity/Snowflake; + public fun getKord ()Ldev/kord/core/Kord; + public final fun getSkuIds ()Ljava/util/List; + public final fun getStartsAt ()Lkotlinx/datetime/Instant; + public final fun getStatus ()Ldev/kord/common/entity/SubscriptionStatus; + public final fun getUser ()Ldev/kord/core/behavior/UserBehavior; + public final fun getUserId ()Ldev/kord/common/entity/Snowflake; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; } public abstract interface class dev/kord/core/event/Event : dev/kord/core/KordObject { @@ -13085,6 +13186,37 @@ public final class dev/kord/core/event/monetization/EntitlementUpdateEvent : dev public fun toString ()Ljava/lang/String; } +public final class dev/kord/core/event/monetization/SubscriptionCreateEvent : dev/kord/core/event/Event { + public fun (Ldev/kord/core/entity/monetization/Subscription;Ldev/kord/core/Kord;ILjava/lang/Object;)V + public fun getCustomContext ()Ljava/lang/Object; + public fun getGateway ()Ldev/kord/gateway/Gateway; + public fun getKord ()Ldev/kord/core/Kord; + public fun getShard ()I + public final fun getSubscription ()Ldev/kord/core/entity/monetization/Subscription; + public fun toString ()Ljava/lang/String; +} + +public final class dev/kord/core/event/monetization/SubscriptionDeleteEvent : dev/kord/core/event/Event { + public fun (Ldev/kord/core/entity/monetization/Subscription;Ldev/kord/core/Kord;ILjava/lang/Object;)V + public fun getCustomContext ()Ljava/lang/Object; + public fun getGateway ()Ldev/kord/gateway/Gateway; + public fun getKord ()Ldev/kord/core/Kord; + public fun getShard ()I + public final fun getSubscription ()Ldev/kord/core/entity/monetization/Subscription; + public fun toString ()Ljava/lang/String; +} + +public final class dev/kord/core/event/monetization/SubscriptionUpdateEvent : dev/kord/core/event/Event { + public fun (Ldev/kord/core/entity/monetization/Subscription;Ldev/kord/core/entity/monetization/Subscription;Ldev/kord/core/Kord;ILjava/lang/Object;)V + public fun getCustomContext ()Ljava/lang/Object; + public fun getGateway ()Ldev/kord/gateway/Gateway; + public fun getKord ()Ldev/kord/core/Kord; + public final fun getOld ()Ldev/kord/core/entity/monetization/Subscription; + public fun getShard ()I + public final fun getSubscription ()Ldev/kord/core/entity/monetization/Subscription; + public fun toString ()Ljava/lang/String; +} + public final class dev/kord/core/event/role/RoleCreateEvent : dev/kord/core/entity/Strategizable, dev/kord/core/event/Event { public fun (Ldev/kord/core/entity/Role;ILjava/lang/Object;Ldev/kord/core/supplier/EntitySupplier;)V public synthetic fun (Ldev/kord/core/entity/Role;ILjava/lang/Object;Ldev/kord/core/supplier/EntitySupplier;ILkotlin/jvm/internal/DefaultConstructorMarker;)V @@ -13215,6 +13347,7 @@ public final class dev/kord/core/exception/EntityNotFoundException$Companion { public final fun selfNotFound ()Ljava/lang/Void; public final fun stageInstanceNotFound (Ldev/kord/common/entity/Snowflake;)Ljava/lang/Void; public final fun stickerNotFound (Ldev/kord/common/entity/Snowflake;)Ljava/lang/Void; + public final fun subscriptionNotFound (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ljava/lang/Void; public final fun templateNotFound (Ljava/lang/String;)Ljava/lang/Void; public final fun userNotFound (Ldev/kord/common/entity/Snowflake;)Ljava/lang/Void; public final fun webhookMessageNotFound (Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;)Ljava/lang/Void; @@ -13676,6 +13809,9 @@ public final class dev/kord/core/supplier/CacheEntitySupplier : dev/kord/core/su public fun getStageInstanceOrNull (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; 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; + public fun getSubscription (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun getSubscriptionOrNull (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun getSubscriptions (Ldev/kord/common/entity/Snowflake;Ldev/kord/rest/json/request/SkuSubscriptionsListRequest;)Lkotlinx/coroutines/flow/Flow; public fun getTemplate (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getTemplateOrNull (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getTemplates (Ldev/kord/common/entity/Snowflake;)Lkotlinx/coroutines/flow/Flow; @@ -13764,6 +13900,9 @@ public abstract interface class dev/kord/core/supplier/EntitySupplier { public abstract fun getStageInstanceOrNull (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun getSticker (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun getStickerOrNull (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun getSubscription (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun getSubscriptionOrNull (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun getSubscriptions (Ldev/kord/common/entity/Snowflake;Ldev/kord/rest/json/request/SkuSubscriptionsListRequest;)Lkotlinx/coroutines/flow/Flow; public abstract fun getTemplate (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun getTemplateOrNull (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun getTemplates (Ldev/kord/common/entity/Snowflake;)Lkotlinx/coroutines/flow/Flow; @@ -13817,6 +13956,7 @@ public final class dev/kord/core/supplier/EntitySupplier$DefaultImpls { public static fun getSelf (Ldev/kord/core/supplier/EntitySupplier;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static fun getStageInstance (Ldev/kord/core/supplier/EntitySupplier;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static fun getSticker (Ldev/kord/core/supplier/EntitySupplier;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun getSubscription (Ldev/kord/core/supplier/EntitySupplier;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static fun getTemplate (Ldev/kord/core/supplier/EntitySupplier;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static fun getUser (Ldev/kord/core/supplier/EntitySupplier;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static fun getWebhook (Ldev/kord/core/supplier/EntitySupplier;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -13933,6 +14073,9 @@ public final class dev/kord/core/supplier/RestEntitySupplier : dev/kord/core/sup public fun getStageInstanceOrNull (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; 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; + public fun getSubscription (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun getSubscriptionOrNull (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun getSubscriptions (Ldev/kord/common/entity/Snowflake;Ldev/kord/rest/json/request/SkuSubscriptionsListRequest;)Lkotlinx/coroutines/flow/Flow; public fun getTemplate (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getTemplateOrNull (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getTemplates (Ldev/kord/common/entity/Snowflake;)Lkotlinx/coroutines/flow/Flow; @@ -14021,6 +14164,9 @@ public final class dev/kord/core/supplier/StoreEntitySupplier : dev/kord/core/su public fun getStageInstanceOrNull (Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; 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; + public fun getSubscription (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun getSubscriptionOrNull (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun getSubscriptions (Ldev/kord/common/entity/Snowflake;Ldev/kord/rest/json/request/SkuSubscriptionsListRequest;)Lkotlinx/coroutines/flow/Flow; public fun getTemplate (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getTemplateOrNull (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getTemplates (Ldev/kord/common/entity/Snowflake;)Lkotlinx/coroutines/flow/Flow; diff --git a/core/api/core.klib.api b/core/api/core.klib.api index 910f147b655..ae82386e41f 100644 --- a/core/api/core.klib.api +++ b/core/api/core.klib.api @@ -406,6 +406,18 @@ abstract interface dev.kord.core.behavior.interaction/ModalParentInteractionBeha abstract fun withStrategy(dev.kord.core.supplier/EntitySupplyStrategy<*>): dev.kord.core.behavior.interaction/ModalParentInteractionBehavior // dev.kord.core.behavior.interaction/ModalParentInteractionBehavior.withStrategy|withStrategy(dev.kord.core.supplier.EntitySupplyStrategy<*>){}[0] } +abstract interface dev.kord.core.behavior.monetization/SkuBehavior : dev.kord.core.entity/KordEntity, dev.kord.core.entity/Strategizable { // dev.kord.core.behavior.monetization/SkuBehavior|null[0] + abstract val applicationId // dev.kord.core.behavior.monetization/SkuBehavior.applicationId|{}applicationId[0] + abstract fun (): dev.kord.common.entity/Snowflake // dev.kord.core.behavior.monetization/SkuBehavior.applicationId.|(){}[0] + + abstract fun withStrategy(dev.kord.core.supplier/EntitySupplyStrategy<*>): dev.kord.core.behavior.monetization/SkuBehavior // dev.kord.core.behavior.monetization/SkuBehavior.withStrategy|withStrategy(dev.kord.core.supplier.EntitySupplyStrategy<*>){}[0] + open suspend fun createTestEntitlement(dev.kord.common.entity/Snowflake, dev.kord.common.entity/EntitlementOwnerType): dev.kord.core.entity.monetization/Entitlement // dev.kord.core.behavior.monetization/SkuBehavior.createTestEntitlement|createTestEntitlement(dev.kord.common.entity.Snowflake;dev.kord.common.entity.EntitlementOwnerType){}[0] + open suspend fun createTestEntitlement(dev.kord.common.entity/Snowflake, dev.kord.core.behavior/GuildBehavior): dev.kord.core.entity.monetization/Entitlement // dev.kord.core.behavior.monetization/SkuBehavior.createTestEntitlement|createTestEntitlement(dev.kord.common.entity.Snowflake;dev.kord.core.behavior.GuildBehavior){}[0] + open suspend fun createTestEntitlement(dev.kord.common.entity/Snowflake, dev.kord.core.behavior/UserBehavior): dev.kord.core.entity.monetization/Entitlement // dev.kord.core.behavior.monetization/SkuBehavior.createTestEntitlement|createTestEntitlement(dev.kord.common.entity.Snowflake;dev.kord.core.behavior.UserBehavior){}[0] + open suspend fun getSubscription(dev.kord.common.entity/Snowflake): dev.kord.core.entity.monetization/Subscription // dev.kord.core.behavior.monetization/SkuBehavior.getSubscription|getSubscription(dev.kord.common.entity.Snowflake){}[0] + open suspend fun getSubscriptionOrNull(dev.kord.common.entity/Snowflake): dev.kord.core.entity.monetization/Subscription? // dev.kord.core.behavior.monetization/SkuBehavior.getSubscriptionOrNull|getSubscriptionOrNull(dev.kord.common.entity.Snowflake){}[0] +} + abstract interface dev.kord.core.behavior/ApplicationCommandBehavior : dev.kord.core.entity/Entity { // dev.kord.core.behavior/ApplicationCommandBehavior|null[0] abstract val applicationId // dev.kord.core.behavior/ApplicationCommandBehavior.applicationId|{}applicationId[0] abstract fun (): dev.kord.common.entity/Snowflake // dev.kord.core.behavior/ApplicationCommandBehavior.applicationId.|(){}[0] @@ -950,6 +962,7 @@ abstract interface dev.kord.core.supplier/EntitySupplier { // dev.kord.core.supp abstract fun getNitroStickerPacks(): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/EntitySupplier.getNitroStickerPacks|getNitroStickerPacks(){}[0] abstract fun getPrivateArchivedThreads(dev.kord.common.entity/Snowflake, kotlinx.datetime/Instant? = ..., kotlin/Int? = ...): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/EntitySupplier.getPrivateArchivedThreads|getPrivateArchivedThreads(dev.kord.common.entity.Snowflake;kotlinx.datetime.Instant?;kotlin.Int?){}[0] abstract fun getPublicArchivedThreads(dev.kord.common.entity/Snowflake, kotlinx.datetime/Instant? = ..., kotlin/Int? = ...): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/EntitySupplier.getPublicArchivedThreads|getPublicArchivedThreads(dev.kord.common.entity.Snowflake;kotlinx.datetime.Instant?;kotlin.Int?){}[0] + abstract fun getSubscriptions(dev.kord.common.entity/Snowflake, dev.kord.rest.json.request/SkuSubscriptionsListRequest): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/EntitySupplier.getSubscriptions|getSubscriptions(dev.kord.common.entity.Snowflake;dev.kord.rest.json.request.SkuSubscriptionsListRequest){}[0] abstract fun getTemplates(dev.kord.common.entity/Snowflake): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/EntitySupplier.getTemplates|getTemplates(dev.kord.common.entity.Snowflake){}[0] abstract fun getThreadMembers(dev.kord.common.entity/Snowflake): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/EntitySupplier.getThreadMembers|getThreadMembers(dev.kord.common.entity.Snowflake){}[0] abstract suspend fun getApplicationCommandPermissionsOrNull(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.entity.application/ApplicationCommandPermissions? // dev.kord.core.supplier/EntitySupplier.getApplicationCommandPermissionsOrNull|getApplicationCommandPermissionsOrNull(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] @@ -971,6 +984,7 @@ abstract interface dev.kord.core.supplier/EntitySupplier { // dev.kord.core.supp abstract suspend fun getSelfOrNull(): dev.kord.core.entity/User? // dev.kord.core.supplier/EntitySupplier.getSelfOrNull|getSelfOrNull(){}[0] abstract suspend fun getStageInstanceOrNull(dev.kord.common.entity/Snowflake): dev.kord.core.entity/StageInstance? // dev.kord.core.supplier/EntitySupplier.getStageInstanceOrNull|getStageInstanceOrNull(dev.kord.common.entity.Snowflake){}[0] abstract suspend fun getStickerOrNull(dev.kord.common.entity/Snowflake): dev.kord.core.entity/Sticker? // dev.kord.core.supplier/EntitySupplier.getStickerOrNull|getStickerOrNull(dev.kord.common.entity.Snowflake){}[0] + abstract suspend fun getSubscriptionOrNull(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.entity.monetization/Subscription? // dev.kord.core.supplier/EntitySupplier.getSubscriptionOrNull|getSubscriptionOrNull(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] abstract suspend fun getTemplateOrNull(kotlin/String): dev.kord.core.entity/Template? // dev.kord.core.supplier/EntitySupplier.getTemplateOrNull|getTemplateOrNull(kotlin.String){}[0] abstract suspend fun getUserOrNull(dev.kord.common.entity/Snowflake): dev.kord.core.entity/User? // dev.kord.core.supplier/EntitySupplier.getUserOrNull|getUserOrNull(dev.kord.common.entity.Snowflake){}[0] abstract suspend fun getWebhookMessageOrNull(dev.kord.common.entity/Snowflake, kotlin/String, dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake? = ...): dev.kord.core.entity/Message? // dev.kord.core.supplier/EntitySupplier.getWebhookMessageOrNull|getWebhookMessageOrNull(dev.kord.common.entity.Snowflake;kotlin.String;dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake?){}[0] @@ -997,6 +1011,7 @@ abstract interface dev.kord.core.supplier/EntitySupplier { // dev.kord.core.supp open suspend fun getSelf(): dev.kord.core.entity/User // dev.kord.core.supplier/EntitySupplier.getSelf|getSelf(){}[0] open suspend fun getStageInstance(dev.kord.common.entity/Snowflake): dev.kord.core.entity/StageInstance // dev.kord.core.supplier/EntitySupplier.getStageInstance|getStageInstance(dev.kord.common.entity.Snowflake){}[0] open suspend fun getSticker(dev.kord.common.entity/Snowflake): dev.kord.core.entity/Sticker // dev.kord.core.supplier/EntitySupplier.getSticker|getSticker(dev.kord.common.entity.Snowflake){}[0] + open suspend fun getSubscription(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.entity.monetization/Subscription // dev.kord.core.supplier/EntitySupplier.getSubscription|getSubscription(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] open suspend fun getTemplate(kotlin/String): dev.kord.core.entity/Template // dev.kord.core.supplier/EntitySupplier.getTemplate|getTemplate(kotlin.String){}[0] open suspend fun getUser(dev.kord.common.entity/Snowflake): dev.kord.core.entity/User // dev.kord.core.supplier/EntitySupplier.getUser|getUser(dev.kord.common.entity.Snowflake){}[0] open suspend fun getWebhook(dev.kord.common.entity/Snowflake): dev.kord.core.entity/Webhook // dev.kord.core.supplier/EntitySupplier.getWebhook|getWebhook(dev.kord.common.entity.Snowflake){}[0] @@ -5037,6 +5052,61 @@ final class dev.kord.core.cache.data/StickerPackData { // dev.kord.core.cache.da } } +final class dev.kord.core.cache.data/SubscriptionData { // dev.kord.core.cache.data/SubscriptionData|null[0] + constructor (dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake, kotlin.collections/List, kotlin.collections/List, kotlinx.datetime/Instant, kotlinx.datetime/Instant, dev.kord.common.entity/SubscriptionStatus, kotlinx.datetime/Instant?, dev.kord.common.entity.optional/Optional = ...) // dev.kord.core.cache.data/SubscriptionData.|(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake;kotlin.collections.List;kotlin.collections.List;kotlinx.datetime.Instant;kotlinx.datetime.Instant;dev.kord.common.entity.SubscriptionStatus;kotlinx.datetime.Instant?;dev.kord.common.entity.optional.Optional){}[0] + + final val canceledAt // dev.kord.core.cache.data/SubscriptionData.canceledAt|{}canceledAt[0] + final fun (): kotlinx.datetime/Instant? // dev.kord.core.cache.data/SubscriptionData.canceledAt.|(){}[0] + final val country // dev.kord.core.cache.data/SubscriptionData.country|{}country[0] + final fun (): dev.kord.common.entity.optional/Optional // dev.kord.core.cache.data/SubscriptionData.country.|(){}[0] + final val currentPeriodEnd // dev.kord.core.cache.data/SubscriptionData.currentPeriodEnd|{}currentPeriodEnd[0] + final fun (): kotlinx.datetime/Instant // dev.kord.core.cache.data/SubscriptionData.currentPeriodEnd.|(){}[0] + final val currentPeriodStart // dev.kord.core.cache.data/SubscriptionData.currentPeriodStart|{}currentPeriodStart[0] + final fun (): kotlinx.datetime/Instant // dev.kord.core.cache.data/SubscriptionData.currentPeriodStart.|(){}[0] + final val entitlementIds // dev.kord.core.cache.data/SubscriptionData.entitlementIds|{}entitlementIds[0] + final fun (): kotlin.collections/List // dev.kord.core.cache.data/SubscriptionData.entitlementIds.|(){}[0] + final val id // dev.kord.core.cache.data/SubscriptionData.id|{}id[0] + final fun (): dev.kord.common.entity/Snowflake // dev.kord.core.cache.data/SubscriptionData.id.|(){}[0] + final val skuIds // dev.kord.core.cache.data/SubscriptionData.skuIds|{}skuIds[0] + final fun (): kotlin.collections/List // dev.kord.core.cache.data/SubscriptionData.skuIds.|(){}[0] + final val status // dev.kord.core.cache.data/SubscriptionData.status|{}status[0] + final fun (): dev.kord.common.entity/SubscriptionStatus // dev.kord.core.cache.data/SubscriptionData.status.|(){}[0] + final val userId // dev.kord.core.cache.data/SubscriptionData.userId|{}userId[0] + final fun (): dev.kord.common.entity/Snowflake // dev.kord.core.cache.data/SubscriptionData.userId.|(){}[0] + + final fun component1(): dev.kord.common.entity/Snowflake // dev.kord.core.cache.data/SubscriptionData.component1|component1(){}[0] + final fun component2(): dev.kord.common.entity/Snowflake // dev.kord.core.cache.data/SubscriptionData.component2|component2(){}[0] + final fun component3(): kotlin.collections/List // dev.kord.core.cache.data/SubscriptionData.component3|component3(){}[0] + final fun component4(): kotlin.collections/List // dev.kord.core.cache.data/SubscriptionData.component4|component4(){}[0] + final fun component5(): kotlinx.datetime/Instant // dev.kord.core.cache.data/SubscriptionData.component5|component5(){}[0] + final fun component6(): kotlinx.datetime/Instant // dev.kord.core.cache.data/SubscriptionData.component6|component6(){}[0] + final fun component7(): dev.kord.common.entity/SubscriptionStatus // dev.kord.core.cache.data/SubscriptionData.component7|component7(){}[0] + final fun component8(): kotlinx.datetime/Instant? // dev.kord.core.cache.data/SubscriptionData.component8|component8(){}[0] + final fun component9(): dev.kord.common.entity.optional/Optional // dev.kord.core.cache.data/SubscriptionData.component9|component9(){}[0] + final fun copy(dev.kord.common.entity/Snowflake = ..., dev.kord.common.entity/Snowflake = ..., kotlin.collections/List = ..., kotlin.collections/List = ..., kotlinx.datetime/Instant = ..., kotlinx.datetime/Instant = ..., dev.kord.common.entity/SubscriptionStatus = ..., kotlinx.datetime/Instant? = ..., dev.kord.common.entity.optional/Optional = ...): dev.kord.core.cache.data/SubscriptionData // dev.kord.core.cache.data/SubscriptionData.copy|copy(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake;kotlin.collections.List;kotlin.collections.List;kotlinx.datetime.Instant;kotlinx.datetime.Instant;dev.kord.common.entity.SubscriptionStatus;kotlinx.datetime.Instant?;dev.kord.common.entity.optional.Optional){}[0] + final fun equals(kotlin/Any?): kotlin/Boolean // dev.kord.core.cache.data/SubscriptionData.equals|equals(kotlin.Any?){}[0] + final fun hashCode(): kotlin/Int // dev.kord.core.cache.data/SubscriptionData.hashCode|hashCode(){}[0] + final fun toString(): kotlin/String // dev.kord.core.cache.data/SubscriptionData.toString|toString(){}[0] + + final object $serializer : kotlinx.serialization.internal/GeneratedSerializer { // dev.kord.core.cache.data/SubscriptionData.$serializer|null[0] + final val descriptor // dev.kord.core.cache.data/SubscriptionData.$serializer.descriptor|{}descriptor[0] + final fun (): kotlinx.serialization.descriptors/SerialDescriptor // dev.kord.core.cache.data/SubscriptionData.$serializer.descriptor.|(){}[0] + + final fun childSerializers(): kotlin/Array> // dev.kord.core.cache.data/SubscriptionData.$serializer.childSerializers|childSerializers(){}[0] + final fun deserialize(kotlinx.serialization.encoding/Decoder): dev.kord.core.cache.data/SubscriptionData // dev.kord.core.cache.data/SubscriptionData.$serializer.deserialize|deserialize(kotlinx.serialization.encoding.Decoder){}[0] + final fun serialize(kotlinx.serialization.encoding/Encoder, dev.kord.core.cache.data/SubscriptionData) // dev.kord.core.cache.data/SubscriptionData.$serializer.serialize|serialize(kotlinx.serialization.encoding.Encoder;dev.kord.core.cache.data.SubscriptionData){}[0] + } + + final object Companion { // dev.kord.core.cache.data/SubscriptionData.Companion|null[0] + final val $childSerializers // dev.kord.core.cache.data/SubscriptionData.Companion.$childSerializers|{}$childSerializers[0] + final val description // dev.kord.core.cache.data/SubscriptionData.Companion.description|{}description[0] + final fun (): dev.kord.cache.api.data/DataDescription // dev.kord.core.cache.data/SubscriptionData.Companion.description.|(){}[0] + + final fun from(dev.kord.common.entity/DiscordSubscription): dev.kord.core.cache.data/SubscriptionData // dev.kord.core.cache.data/SubscriptionData.Companion.from|from(dev.kord.common.entity.DiscordSubscription){}[0] + final fun serializer(): kotlinx.serialization/KSerializer // dev.kord.core.cache.data/SubscriptionData.Companion.serializer|serializer(){}[0] + } +} + final class dev.kord.core.cache.data/TeamData { // dev.kord.core.cache.data/TeamData|null[0] constructor (dev.kord.common.entity/Snowflake, kotlin/String? = ..., kotlin.collections/List, dev.kord.common.entity/Snowflake, kotlin/String) // dev.kord.core.cache.data/TeamData.|(dev.kord.common.entity.Snowflake;kotlin.String?;kotlin.collections.List;dev.kord.common.entity.Snowflake;kotlin.String){}[0] @@ -5669,6 +5739,7 @@ final class dev.kord.core.cache/KordCacheBuilder { // dev.kord.core.cache/KordCa final fun presences(kotlin/Function2, dev.kord.cache.api/DataEntryCache>) // dev.kord.core.cache/KordCacheBuilder.presences|presences(kotlin.Function2,dev.kord.cache.api.DataEntryCache>){}[0] final fun roles(kotlin/Function2, dev.kord.cache.api/DataEntryCache>) // dev.kord.core.cache/KordCacheBuilder.roles|roles(kotlin.Function2,dev.kord.cache.api.DataEntryCache>){}[0] final fun stickers(kotlin/Function2, dev.kord.cache.api/DataEntryCache>) // dev.kord.core.cache/KordCacheBuilder.stickers|stickers(kotlin.Function2,dev.kord.cache.api.DataEntryCache>){}[0] + final fun subscriptions(kotlin/Function2, dev.kord.cache.api/DataEntryCache>) // dev.kord.core.cache/KordCacheBuilder.subscriptions|subscriptions(kotlin.Function2,dev.kord.cache.api.DataEntryCache>){}[0] final fun users(kotlin/Function2, dev.kord.cache.api/DataEntryCache>) // dev.kord.core.cache/KordCacheBuilder.users|users(kotlin.Function2,dev.kord.cache.api.DataEntryCache>){}[0] final fun voiceState(kotlin/Function2, dev.kord.cache.api/DataEntryCache>) // dev.kord.core.cache/KordCacheBuilder.voiceState|voiceState(kotlin.Function2,dev.kord.cache.api.DataEntryCache>){}[0] final fun webhooks(kotlin/Function2, dev.kord.cache.api/DataEntryCache>) // dev.kord.core.cache/KordCacheBuilder.webhooks|webhooks(kotlin.Function2,dev.kord.cache.api.DataEntryCache>){}[0] @@ -6917,8 +6988,8 @@ final class dev.kord.core.entity.monetization/Entitlement : dev.kord.core.entity final suspend fun delete() // dev.kord.core.entity.monetization/Entitlement.delete|delete(){}[0] } -final class dev.kord.core.entity.monetization/Sku : dev.kord.core.entity/KordEntity { // dev.kord.core.entity.monetization/Sku|null[0] - constructor (dev.kord.common.entity/DiscordSku, dev.kord.core/Kord) // dev.kord.core.entity.monetization/Sku.|(dev.kord.common.entity.DiscordSku;dev.kord.core.Kord){}[0] +final class dev.kord.core.entity.monetization/Sku : dev.kord.core.behavior.monetization/SkuBehavior { // dev.kord.core.entity.monetization/Sku|null[0] + constructor (dev.kord.common.entity/DiscordSku, dev.kord.core/Kord, dev.kord.core.supplier/EntitySupplier = ...) // dev.kord.core.entity.monetization/Sku.|(dev.kord.common.entity.DiscordSku;dev.kord.core.Kord;dev.kord.core.supplier.EntitySupplier){}[0] final val applicationId // dev.kord.core.entity.monetization/Sku.applicationId|{}applicationId[0] final fun (): dev.kord.common.entity/Snowflake // dev.kord.core.entity.monetization/Sku.applicationId.|(){}[0] @@ -6934,12 +7005,50 @@ final class dev.kord.core.entity.monetization/Sku : dev.kord.core.entity/KordEnt final fun (): kotlin/String // dev.kord.core.entity.monetization/Sku.name.|(){}[0] final val slug // dev.kord.core.entity.monetization/Sku.slug|{}slug[0] final fun (): kotlin/String // dev.kord.core.entity.monetization/Sku.slug.|(){}[0] + final val supplier // dev.kord.core.entity.monetization/Sku.supplier|{}supplier[0] + final fun (): dev.kord.core.supplier/EntitySupplier // dev.kord.core.entity.monetization/Sku.supplier.|(){}[0] final val type // dev.kord.core.entity.monetization/Sku.type|{}type[0] final fun (): dev.kord.common.entity/SkuType // dev.kord.core.entity.monetization/Sku.type.|(){}[0] final fun equals(kotlin/Any?): kotlin/Boolean // dev.kord.core.entity.monetization/Sku.equals|equals(kotlin.Any?){}[0] final fun hashCode(): kotlin/Int // dev.kord.core.entity.monetization/Sku.hashCode|hashCode(){}[0] final fun toString(): kotlin/String // dev.kord.core.entity.monetization/Sku.toString|toString(){}[0] + final fun withStrategy(dev.kord.core.supplier/EntitySupplyStrategy<*>): dev.kord.core.entity.monetization/Sku // dev.kord.core.entity.monetization/Sku.withStrategy|withStrategy(dev.kord.core.supplier.EntitySupplyStrategy<*>){}[0] +} + +final class dev.kord.core.entity.monetization/Subscription : dev.kord.core.entity/KordEntity { // dev.kord.core.entity.monetization/Subscription|null[0] + constructor (dev.kord.core.cache.data/SubscriptionData, dev.kord.core/Kord) // dev.kord.core.entity.monetization/Subscription.|(dev.kord.core.cache.data.SubscriptionData;dev.kord.core.Kord){}[0] + + final val canceledAt // dev.kord.core.entity.monetization/Subscription.canceledAt|{}canceledAt[0] + final fun (): kotlinx.datetime/Instant? // dev.kord.core.entity.monetization/Subscription.canceledAt.|(){}[0] + final val country // dev.kord.core.entity.monetization/Subscription.country|{}country[0] + final fun (): kotlin/String? // dev.kord.core.entity.monetization/Subscription.country.|(){}[0] + final val currentPeriodEnd // dev.kord.core.entity.monetization/Subscription.currentPeriodEnd|{}currentPeriodEnd[0] + final fun (): kotlinx.datetime/Instant // dev.kord.core.entity.monetization/Subscription.currentPeriodEnd.|(){}[0] + final val currentPeriodStart // dev.kord.core.entity.monetization/Subscription.currentPeriodStart|{}currentPeriodStart[0] + final fun (): kotlinx.datetime/Instant // dev.kord.core.entity.monetization/Subscription.currentPeriodStart.|(){}[0] + final val data // dev.kord.core.entity.monetization/Subscription.data|{}data[0] + final fun (): dev.kord.core.cache.data/SubscriptionData // dev.kord.core.entity.monetization/Subscription.data.|(){}[0] + final val entitlementIds // dev.kord.core.entity.monetization/Subscription.entitlementIds|{}entitlementIds[0] + final fun (): kotlin.collections/List // dev.kord.core.entity.monetization/Subscription.entitlementIds.|(){}[0] + final val id // dev.kord.core.entity.monetization/Subscription.id|{}id[0] + final fun (): dev.kord.common.entity/Snowflake // dev.kord.core.entity.monetization/Subscription.id.|(){}[0] + final val kord // dev.kord.core.entity.monetization/Subscription.kord|{}kord[0] + final fun (): dev.kord.core/Kord // dev.kord.core.entity.monetization/Subscription.kord.|(){}[0] + final val skuIds // dev.kord.core.entity.monetization/Subscription.skuIds|{}skuIds[0] + final fun (): kotlin.collections/List // dev.kord.core.entity.monetization/Subscription.skuIds.|(){}[0] + final val startsAt // dev.kord.core.entity.monetization/Subscription.startsAt|{}startsAt[0] + final fun (): kotlinx.datetime/Instant // dev.kord.core.entity.monetization/Subscription.startsAt.|(){}[0] + final val status // dev.kord.core.entity.monetization/Subscription.status|{}status[0] + final fun (): dev.kord.common.entity/SubscriptionStatus // dev.kord.core.entity.monetization/Subscription.status.|(){}[0] + final val user // dev.kord.core.entity.monetization/Subscription.user|{}user[0] + final fun (): dev.kord.core.behavior/UserBehavior // dev.kord.core.entity.monetization/Subscription.user.|(){}[0] + final val userId // dev.kord.core.entity.monetization/Subscription.userId|{}userId[0] + final fun (): dev.kord.common.entity/Snowflake // dev.kord.core.entity.monetization/Subscription.userId.|(){}[0] + + final fun equals(kotlin/Any?): kotlin/Boolean // dev.kord.core.entity.monetization/Subscription.equals|equals(kotlin.Any?){}[0] + final fun hashCode(): kotlin/Int // dev.kord.core.entity.monetization/Subscription.hashCode|hashCode(){}[0] + final fun toString(): kotlin/String // dev.kord.core.entity.monetization/Subscription.toString|toString(){}[0] } final class dev.kord.core.entity/Activity { // dev.kord.core.entity/Activity|null[0] @@ -10870,6 +10979,53 @@ final class dev.kord.core.event.monetization/EntitlementUpdateEvent : dev.kord.c final fun toString(): kotlin/String // dev.kord.core.event.monetization/EntitlementUpdateEvent.toString|toString(){}[0] } +final class dev.kord.core.event.monetization/SubscriptionCreateEvent : dev.kord.core.event/Event { // dev.kord.core.event.monetization/SubscriptionCreateEvent|null[0] + constructor (dev.kord.core.entity.monetization/Subscription, dev.kord.core/Kord, kotlin/Int, kotlin/Any?) // dev.kord.core.event.monetization/SubscriptionCreateEvent.|(dev.kord.core.entity.monetization.Subscription;dev.kord.core.Kord;kotlin.Int;kotlin.Any?){}[0] + + final val customContext // dev.kord.core.event.monetization/SubscriptionCreateEvent.customContext|{}customContext[0] + final fun (): kotlin/Any? // dev.kord.core.event.monetization/SubscriptionCreateEvent.customContext.|(){}[0] + final val kord // dev.kord.core.event.monetization/SubscriptionCreateEvent.kord|{}kord[0] + final fun (): dev.kord.core/Kord // dev.kord.core.event.monetization/SubscriptionCreateEvent.kord.|(){}[0] + final val shard // dev.kord.core.event.monetization/SubscriptionCreateEvent.shard|{}shard[0] + final fun (): kotlin/Int // dev.kord.core.event.monetization/SubscriptionCreateEvent.shard.|(){}[0] + final val subscription // dev.kord.core.event.monetization/SubscriptionCreateEvent.subscription|{}subscription[0] + final fun (): dev.kord.core.entity.monetization/Subscription // dev.kord.core.event.monetization/SubscriptionCreateEvent.subscription.|(){}[0] + + final fun toString(): kotlin/String // dev.kord.core.event.monetization/SubscriptionCreateEvent.toString|toString(){}[0] +} + +final class dev.kord.core.event.monetization/SubscriptionDeleteEvent : dev.kord.core.event/Event { // dev.kord.core.event.monetization/SubscriptionDeleteEvent|null[0] + constructor (dev.kord.core.entity.monetization/Subscription, dev.kord.core/Kord, kotlin/Int, kotlin/Any?) // dev.kord.core.event.monetization/SubscriptionDeleteEvent.|(dev.kord.core.entity.monetization.Subscription;dev.kord.core.Kord;kotlin.Int;kotlin.Any?){}[0] + + final val customContext // dev.kord.core.event.monetization/SubscriptionDeleteEvent.customContext|{}customContext[0] + final fun (): kotlin/Any? // dev.kord.core.event.monetization/SubscriptionDeleteEvent.customContext.|(){}[0] + final val kord // dev.kord.core.event.monetization/SubscriptionDeleteEvent.kord|{}kord[0] + final fun (): dev.kord.core/Kord // dev.kord.core.event.monetization/SubscriptionDeleteEvent.kord.|(){}[0] + final val shard // dev.kord.core.event.monetization/SubscriptionDeleteEvent.shard|{}shard[0] + final fun (): kotlin/Int // dev.kord.core.event.monetization/SubscriptionDeleteEvent.shard.|(){}[0] + final val subscription // dev.kord.core.event.monetization/SubscriptionDeleteEvent.subscription|{}subscription[0] + final fun (): dev.kord.core.entity.monetization/Subscription // dev.kord.core.event.monetization/SubscriptionDeleteEvent.subscription.|(){}[0] + + final fun toString(): kotlin/String // dev.kord.core.event.monetization/SubscriptionDeleteEvent.toString|toString(){}[0] +} + +final class dev.kord.core.event.monetization/SubscriptionUpdateEvent : dev.kord.core.event/Event { // dev.kord.core.event.monetization/SubscriptionUpdateEvent|null[0] + constructor (dev.kord.core.entity.monetization/Subscription, dev.kord.core.entity.monetization/Subscription?, dev.kord.core/Kord, kotlin/Int, kotlin/Any?) // dev.kord.core.event.monetization/SubscriptionUpdateEvent.|(dev.kord.core.entity.monetization.Subscription;dev.kord.core.entity.monetization.Subscription?;dev.kord.core.Kord;kotlin.Int;kotlin.Any?){}[0] + + final val customContext // dev.kord.core.event.monetization/SubscriptionUpdateEvent.customContext|{}customContext[0] + final fun (): kotlin/Any? // dev.kord.core.event.monetization/SubscriptionUpdateEvent.customContext.|(){}[0] + final val kord // dev.kord.core.event.monetization/SubscriptionUpdateEvent.kord|{}kord[0] + final fun (): dev.kord.core/Kord // dev.kord.core.event.monetization/SubscriptionUpdateEvent.kord.|(){}[0] + final val old // dev.kord.core.event.monetization/SubscriptionUpdateEvent.old|{}old[0] + final fun (): dev.kord.core.entity.monetization/Subscription? // dev.kord.core.event.monetization/SubscriptionUpdateEvent.old.|(){}[0] + final val shard // dev.kord.core.event.monetization/SubscriptionUpdateEvent.shard|{}shard[0] + final fun (): kotlin/Int // dev.kord.core.event.monetization/SubscriptionUpdateEvent.shard.|(){}[0] + final val subscription // dev.kord.core.event.monetization/SubscriptionUpdateEvent.subscription|{}subscription[0] + final fun (): dev.kord.core.entity.monetization/Subscription // dev.kord.core.event.monetization/SubscriptionUpdateEvent.subscription.|(){}[0] + + final fun toString(): kotlin/String // dev.kord.core.event.monetization/SubscriptionUpdateEvent.toString|toString(){}[0] +} + final class dev.kord.core.event.role/RoleCreateEvent : dev.kord.core.entity/Strategizable, dev.kord.core.event/Event { // dev.kord.core.event.role/RoleCreateEvent|null[0] constructor (dev.kord.core.entity/Role, kotlin/Int, kotlin/Any?, dev.kord.core.supplier/EntitySupplier = ...) // dev.kord.core.event.role/RoleCreateEvent.|(dev.kord.core.entity.Role;kotlin.Int;kotlin.Any?;dev.kord.core.supplier.EntitySupplier){}[0] @@ -11059,6 +11215,7 @@ final class dev.kord.core.exception/EntityNotFoundException : kotlin/Exception { final inline fun selfNotFound(): kotlin/Nothing // dev.kord.core.exception/EntityNotFoundException.Companion.selfNotFound|selfNotFound(){}[0] final inline fun stageInstanceNotFound(dev.kord.common.entity/Snowflake): kotlin/Nothing // dev.kord.core.exception/EntityNotFoundException.Companion.stageInstanceNotFound|stageInstanceNotFound(dev.kord.common.entity.Snowflake){}[0] final inline fun stickerNotFound(dev.kord.common.entity/Snowflake): kotlin/Nothing // dev.kord.core.exception/EntityNotFoundException.Companion.stickerNotFound|stickerNotFound(dev.kord.common.entity.Snowflake){}[0] + final inline fun subscriptionNotFound(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): kotlin/Nothing // dev.kord.core.exception/EntityNotFoundException.Companion.subscriptionNotFound|subscriptionNotFound(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] final inline fun templateNotFound(kotlin/String): kotlin/Nothing // dev.kord.core.exception/EntityNotFoundException.Companion.templateNotFound|templateNotFound(kotlin.String){}[0] final inline fun userNotFound(dev.kord.common.entity/Snowflake): kotlin/Nothing // dev.kord.core.exception/EntityNotFoundException.Companion.userNotFound|userNotFound(dev.kord.common.entity.Snowflake){}[0] final inline fun webhookMessageNotFound(dev.kord.common.entity/Snowflake, kotlin/String, dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake? = ...): kotlin/Nothing // dev.kord.core.exception/EntityNotFoundException.Companion.webhookMessageNotFound|webhookMessageNotFound(dev.kord.common.entity.Snowflake;kotlin.String;dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake?){}[0] @@ -11277,6 +11434,7 @@ final class dev.kord.core.supplier/CacheEntitySupplier : dev.kord.core.supplier/ final fun getNitroStickerPacks(): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/CacheEntitySupplier.getNitroStickerPacks|getNitroStickerPacks(){}[0] final fun getPrivateArchivedThreads(dev.kord.common.entity/Snowflake, kotlinx.datetime/Instant?, kotlin/Int?): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/CacheEntitySupplier.getPrivateArchivedThreads|getPrivateArchivedThreads(dev.kord.common.entity.Snowflake;kotlinx.datetime.Instant?;kotlin.Int?){}[0] final fun getPublicArchivedThreads(dev.kord.common.entity/Snowflake, kotlinx.datetime/Instant?, kotlin/Int?): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/CacheEntitySupplier.getPublicArchivedThreads|getPublicArchivedThreads(dev.kord.common.entity.Snowflake;kotlinx.datetime.Instant?;kotlin.Int?){}[0] + final fun getSubscriptions(dev.kord.common.entity/Snowflake, dev.kord.rest.json.request/SkuSubscriptionsListRequest): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/CacheEntitySupplier.getSubscriptions|getSubscriptions(dev.kord.common.entity.Snowflake;dev.kord.rest.json.request.SkuSubscriptionsListRequest){}[0] final fun getTemplates(dev.kord.common.entity/Snowflake): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/CacheEntitySupplier.getTemplates|getTemplates(dev.kord.common.entity.Snowflake){}[0] final fun getThreadMembers(dev.kord.common.entity/Snowflake): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/CacheEntitySupplier.getThreadMembers|getThreadMembers(dev.kord.common.entity.Snowflake){}[0] final fun toString(): kotlin/String // dev.kord.core.supplier/CacheEntitySupplier.toString|toString(){}[0] @@ -11300,6 +11458,7 @@ final class dev.kord.core.supplier/CacheEntitySupplier : dev.kord.core.supplier/ final suspend fun getSelfOrNull(): dev.kord.core.entity/User? // dev.kord.core.supplier/CacheEntitySupplier.getSelfOrNull|getSelfOrNull(){}[0] final suspend fun getStageInstanceOrNull(dev.kord.common.entity/Snowflake): dev.kord.core.entity/StageInstance? // dev.kord.core.supplier/CacheEntitySupplier.getStageInstanceOrNull|getStageInstanceOrNull(dev.kord.common.entity.Snowflake){}[0] final suspend fun getStickerOrNull(dev.kord.common.entity/Snowflake): dev.kord.core.entity/Sticker? // dev.kord.core.supplier/CacheEntitySupplier.getStickerOrNull|getStickerOrNull(dev.kord.common.entity.Snowflake){}[0] + final suspend fun getSubscriptionOrNull(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.entity.monetization/Subscription? // dev.kord.core.supplier/CacheEntitySupplier.getSubscriptionOrNull|getSubscriptionOrNull(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] final suspend fun getTemplateOrNull(kotlin/String): dev.kord.core.entity/Template? // dev.kord.core.supplier/CacheEntitySupplier.getTemplateOrNull|getTemplateOrNull(kotlin.String){}[0] final suspend fun getUserOrNull(dev.kord.common.entity/Snowflake): dev.kord.core.entity/User? // dev.kord.core.supplier/CacheEntitySupplier.getUserOrNull|getUserOrNull(dev.kord.common.entity.Snowflake){}[0] final suspend fun getWebhookMessageOrNull(dev.kord.common.entity/Snowflake, kotlin/String, dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake?): dev.kord.core.entity/Message? // dev.kord.core.supplier/CacheEntitySupplier.getWebhookMessageOrNull|getWebhookMessageOrNull(dev.kord.common.entity.Snowflake;kotlin.String;dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake?){}[0] @@ -11348,6 +11507,7 @@ final class dev.kord.core.supplier/RestEntitySupplier : dev.kord.core.supplier/E final fun getPrivateArchivedThreads(dev.kord.common.entity/Snowflake, kotlinx.datetime/Instant?, kotlin/Int?): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/RestEntitySupplier.getPrivateArchivedThreads|getPrivateArchivedThreads(dev.kord.common.entity.Snowflake;kotlinx.datetime.Instant?;kotlin.Int?){}[0] final fun getPublicArchivedThreads(dev.kord.common.entity/Snowflake, kotlinx.datetime/Instant?, kotlin/Int?): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/RestEntitySupplier.getPublicArchivedThreads|getPublicArchivedThreads(dev.kord.common.entity.Snowflake;kotlinx.datetime.Instant?;kotlin.Int?){}[0] final fun getReactors(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake, dev.kord.core.entity/ReactionEmoji): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/RestEntitySupplier.getReactors|getReactors(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake;dev.kord.core.entity.ReactionEmoji){}[0] + final fun getSubscriptions(dev.kord.common.entity/Snowflake, dev.kord.rest.json.request/SkuSubscriptionsListRequest): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/RestEntitySupplier.getSubscriptions|getSubscriptions(dev.kord.common.entity.Snowflake;dev.kord.rest.json.request.SkuSubscriptionsListRequest){}[0] final fun getTemplates(dev.kord.common.entity/Snowflake): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/RestEntitySupplier.getTemplates|getTemplates(dev.kord.common.entity.Snowflake){}[0] final fun getThreadMembers(dev.kord.common.entity/Snowflake): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/RestEntitySupplier.getThreadMembers|getThreadMembers(dev.kord.common.entity.Snowflake){}[0] final fun toString(): kotlin/String // dev.kord.core.supplier/RestEntitySupplier.toString|toString(){}[0] @@ -11380,6 +11540,7 @@ final class dev.kord.core.supplier/RestEntitySupplier : dev.kord.core.supplier/E final suspend fun getSelfOrNull(): dev.kord.core.entity/User? // dev.kord.core.supplier/RestEntitySupplier.getSelfOrNull|getSelfOrNull(){}[0] final suspend fun getStageInstanceOrNull(dev.kord.common.entity/Snowflake): dev.kord.core.entity/StageInstance? // dev.kord.core.supplier/RestEntitySupplier.getStageInstanceOrNull|getStageInstanceOrNull(dev.kord.common.entity.Snowflake){}[0] final suspend fun getStickerOrNull(dev.kord.common.entity/Snowflake): dev.kord.core.entity/Sticker? // dev.kord.core.supplier/RestEntitySupplier.getStickerOrNull|getStickerOrNull(dev.kord.common.entity.Snowflake){}[0] + final suspend fun getSubscriptionOrNull(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.entity.monetization/Subscription? // dev.kord.core.supplier/RestEntitySupplier.getSubscriptionOrNull|getSubscriptionOrNull(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] final suspend fun getTemplateOrNull(kotlin/String): dev.kord.core.entity/Template? // dev.kord.core.supplier/RestEntitySupplier.getTemplateOrNull|getTemplateOrNull(kotlin.String){}[0] final suspend fun getUserOrNull(dev.kord.common.entity/Snowflake): dev.kord.core.entity/User? // dev.kord.core.supplier/RestEntitySupplier.getUserOrNull|getUserOrNull(dev.kord.common.entity.Snowflake){}[0] final suspend fun getWebhookMessageOrNull(dev.kord.common.entity/Snowflake, kotlin/String, dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake?): dev.kord.core.entity/Message? // dev.kord.core.supplier/RestEntitySupplier.getWebhookMessageOrNull|getWebhookMessageOrNull(dev.kord.common.entity.Snowflake;kotlin.String;dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake?){}[0] @@ -11424,6 +11585,7 @@ final class dev.kord.core.supplier/StoreEntitySupplier : dev.kord.core.supplier/ final fun getNitroStickerPacks(): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/StoreEntitySupplier.getNitroStickerPacks|getNitroStickerPacks(){}[0] final fun getPrivateArchivedThreads(dev.kord.common.entity/Snowflake, kotlinx.datetime/Instant?, kotlin/Int?): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/StoreEntitySupplier.getPrivateArchivedThreads|getPrivateArchivedThreads(dev.kord.common.entity.Snowflake;kotlinx.datetime.Instant?;kotlin.Int?){}[0] final fun getPublicArchivedThreads(dev.kord.common.entity/Snowflake, kotlinx.datetime/Instant?, kotlin/Int?): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/StoreEntitySupplier.getPublicArchivedThreads|getPublicArchivedThreads(dev.kord.common.entity.Snowflake;kotlinx.datetime.Instant?;kotlin.Int?){}[0] + final fun getSubscriptions(dev.kord.common.entity/Snowflake, dev.kord.rest.json.request/SkuSubscriptionsListRequest): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/StoreEntitySupplier.getSubscriptions|getSubscriptions(dev.kord.common.entity.Snowflake;dev.kord.rest.json.request.SkuSubscriptionsListRequest){}[0] final fun getTemplates(dev.kord.common.entity/Snowflake): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/StoreEntitySupplier.getTemplates|getTemplates(dev.kord.common.entity.Snowflake){}[0] final fun getThreadMembers(dev.kord.common.entity/Snowflake): kotlinx.coroutines.flow/Flow // dev.kord.core.supplier/StoreEntitySupplier.getThreadMembers|getThreadMembers(dev.kord.common.entity.Snowflake){}[0] final fun toString(): kotlin/String // dev.kord.core.supplier/StoreEntitySupplier.toString|toString(){}[0] @@ -11446,6 +11608,7 @@ final class dev.kord.core.supplier/StoreEntitySupplier : dev.kord.core.supplier/ final suspend fun getSelfOrNull(): dev.kord.core.entity/User? // dev.kord.core.supplier/StoreEntitySupplier.getSelfOrNull|getSelfOrNull(){}[0] final suspend fun getStageInstanceOrNull(dev.kord.common.entity/Snowflake): dev.kord.core.entity/StageInstance? // dev.kord.core.supplier/StoreEntitySupplier.getStageInstanceOrNull|getStageInstanceOrNull(dev.kord.common.entity.Snowflake){}[0] final suspend fun getStickerOrNull(dev.kord.common.entity/Snowflake): dev.kord.core.entity/Sticker? // dev.kord.core.supplier/StoreEntitySupplier.getStickerOrNull|getStickerOrNull(dev.kord.common.entity.Snowflake){}[0] + final suspend fun getSubscriptionOrNull(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.entity.monetization/Subscription? // dev.kord.core.supplier/StoreEntitySupplier.getSubscriptionOrNull|getSubscriptionOrNull(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] final suspend fun getTemplateOrNull(kotlin/String): dev.kord.core.entity/Template? // dev.kord.core.supplier/StoreEntitySupplier.getTemplateOrNull|getTemplateOrNull(kotlin.String){}[0] final suspend fun getUserOrNull(dev.kord.common.entity/Snowflake): dev.kord.core.entity/User? // dev.kord.core.supplier/StoreEntitySupplier.getUserOrNull|getUserOrNull(dev.kord.common.entity.Snowflake){}[0] final suspend fun getWebhookMessageOrNull(dev.kord.common.entity/Snowflake, kotlin/String, dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake?): dev.kord.core.entity/Message? // dev.kord.core.supplier/StoreEntitySupplier.getWebhookMessageOrNull|getWebhookMessageOrNull(dev.kord.common.entity.Snowflake;kotlin.String;dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake?){}[0] @@ -11509,9 +11672,6 @@ final class dev.kord.core/Kord : kotlinx.coroutines/CoroutineScope { // dev.kord final inline fun getEntitlements(dev.kord.core.supplier/EntitySupplyStrategy<*> = ..., kotlin/Function1 = ...): kotlinx.coroutines.flow/Flow // dev.kord.core/Kord.getEntitlements|getEntitlements(dev.kord.core.supplier.EntitySupplyStrategy<*>;kotlin.Function1){}[0] final suspend fun <#A1: kotlin/Any?> getGlobalApplicationCommandOf(dev.kord.common.entity/Snowflake): #A1 // dev.kord.core/Kord.getGlobalApplicationCommandOf|getGlobalApplicationCommandOf(dev.kord.common.entity.Snowflake){0§}[0] final suspend fun <#A1: kotlin/Any?> getGlobalApplicationCommandOfOrNull(dev.kord.common.entity/Snowflake): #A1? // dev.kord.core/Kord.getGlobalApplicationCommandOfOrNull|getGlobalApplicationCommandOfOrNull(dev.kord.common.entity.Snowflake){0§}[0] - final suspend fun createTestEntitlement(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake, dev.kord.common.entity/EntitlementOwnerType): dev.kord.core.entity.monetization/Entitlement // dev.kord.core/Kord.createTestEntitlement|createTestEntitlement(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake;dev.kord.common.entity.EntitlementOwnerType){}[0] - final suspend fun createTestEntitlement(dev.kord.common.entity/Snowflake, dev.kord.core.behavior/GuildBehavior): dev.kord.core.entity.monetization/Entitlement // dev.kord.core/Kord.createTestEntitlement|createTestEntitlement(dev.kord.common.entity.Snowflake;dev.kord.core.behavior.GuildBehavior){}[0] - final suspend fun createTestEntitlement(dev.kord.common.entity/Snowflake, dev.kord.core.behavior/UserBehavior): dev.kord.core.entity.monetization/Entitlement // dev.kord.core/Kord.createTestEntitlement|createTestEntitlement(dev.kord.common.entity.Snowflake;dev.kord.core.behavior.UserBehavior){}[0] final suspend fun editSelf(kotlin/Function1): dev.kord.core.entity/User // dev.kord.core/Kord.editSelf|editSelf(kotlin.Function1){}[0] final suspend fun getApplicationInfo(): dev.kord.core.entity/Application // dev.kord.core/Kord.getApplicationInfo|getApplicationInfo(){}[0] final suspend fun getApplicationRoleConnectionMetadataRecords(): kotlin.collections/List // dev.kord.core/Kord.getApplicationRoleConnectionMetadataRecords|getApplicationRoleConnectionMetadataRecords(){}[0] @@ -11585,6 +11745,7 @@ final class dev.kord.core/Unsafe { // dev.kord.core/Unsafe|null[0] final fun privateThreadParent(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.behavior.channel.threads/PrivateThreadParentChannelBehavior // dev.kord.core/Unsafe.privateThreadParent|privateThreadParent(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] final fun publicThreadParent(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.behavior.channel.threads/ThreadParentChannelBehavior // dev.kord.core/Unsafe.publicThreadParent|publicThreadParent(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] final fun role(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.behavior/RoleBehavior // dev.kord.core/Unsafe.role|role(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] + final fun sku(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake = ...): dev.kord.core.behavior.monetization/SkuBehavior // dev.kord.core/Unsafe.sku|sku(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] final fun spamAutoModerationRule(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.behavior.automoderation/SpamAutoModerationRuleBehavior // dev.kord.core/Unsafe.spamAutoModerationRule|spamAutoModerationRule(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] final fun stageInstance(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.behavior/StageInstanceBehavior // dev.kord.core/Unsafe.stageInstance|stageInstance(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] final fun textChannel(dev.kord.common.entity/Snowflake, dev.kord.common.entity/Snowflake): dev.kord.core.behavior.channel/TextChannelBehavior // dev.kord.core/Unsafe.textChannel|textChannel(dev.kord.common.entity.Snowflake;dev.kord.common.entity.Snowflake){}[0] @@ -12261,6 +12422,7 @@ final fun dev.kord.core.entity.interaction/InteractionCommand(dev.kord.core.cach final fun dev.kord.core.entity.interaction/ModalSubmitInteraction(dev.kord.core.cache.data/InteractionData, dev.kord.core/Kord, dev.kord.core.supplier/EntitySupplier = ...): dev.kord.core.entity.interaction/ModalSubmitInteraction // dev.kord.core.entity.interaction/ModalSubmitInteraction|ModalSubmitInteraction(dev.kord.core.cache.data.InteractionData;dev.kord.core.Kord;dev.kord.core.supplier.EntitySupplier){}[0] final fun dev.kord.core.entity.interaction/OptionValue(dev.kord.common.entity/CommandArgument<*>, dev.kord.core.entity.interaction/ResolvedObjects?): dev.kord.core.entity.interaction/OptionValue<*> // dev.kord.core.entity.interaction/OptionValue|OptionValue(dev.kord.common.entity.CommandArgument<*>;dev.kord.core.entity.interaction.ResolvedObjects?){}[0] final fun dev.kord.core/logCaughtThrowable(kotlin/Throwable) // dev.kord.core/logCaughtThrowable|logCaughtThrowable(kotlin.Throwable){}[0] +final inline fun (dev.kord.core.behavior.monetization/SkuBehavior).dev.kord.core.behavior.monetization/getSubscriptions(kotlin/Function1): kotlinx.coroutines.flow/Flow // dev.kord.core.behavior.monetization/getSubscriptions|getSubscriptions@dev.kord.core.behavior.monetization.SkuBehavior(kotlin.Function1){}[0] final inline fun (dev.kord.core.behavior/GuildBehavior).dev.kord.core.behavior/getAuditLogEntries(kotlin/Function1 = ...): kotlinx.coroutines.flow/Flow // dev.kord.core.behavior/getAuditLogEntries|getAuditLogEntries@dev.kord.core.behavior.GuildBehavior(kotlin.Function1){}[0] final inline fun (dev.kord.core.behavior/GuildBehavior).dev.kord.core.behavior/requestMembers(kotlin/Function1 = ...): kotlinx.coroutines.flow/Flow // dev.kord.core.behavior/requestMembers|requestMembers@dev.kord.core.behavior.GuildBehavior(kotlin.Function1){}[0] final inline fun (dev.kord.core.entity.channel/Category).dev.kord.core.live.channel/live(kotlinx.coroutines/CoroutineScope = ..., kotlin/Function1): dev.kord.core.live.channel/LiveCategory // dev.kord.core.live.channel/live|live@dev.kord.core.entity.channel.Category(kotlinx.coroutines.CoroutineScope;kotlin.Function1){}[0] diff --git a/core/src/commonMain/kotlin/Kord.kt b/core/src/commonMain/kotlin/Kord.kt index 199c4075de9..9f49374ee11 100644 --- a/core/src/commonMain/kotlin/Kord.kt +++ b/core/src/commonMain/kotlin/Kord.kt @@ -4,16 +4,12 @@ import dev.kord.cache.api.DataCache import dev.kord.common.annotation.KordExperimental import dev.kord.common.annotation.KordUnsafe import dev.kord.common.entity.DiscordShard -import dev.kord.common.entity.EntitlementOwnerType import dev.kord.common.entity.Snowflake import dev.kord.common.exception.RequestException -import dev.kord.core.behavior.GuildBehavior -import dev.kord.core.behavior.UserBehavior import dev.kord.core.builder.kord.KordBuilder import dev.kord.core.builder.kord.KordProxyBuilder import dev.kord.core.builder.kord.KordRestOnlyBuilder import dev.kord.core.cache.data.ApplicationCommandData -import dev.kord.core.cache.data.EntitlementData import dev.kord.core.cache.data.GuildData import dev.kord.core.cache.data.UserData import dev.kord.core.entity.* @@ -36,7 +32,6 @@ import dev.kord.rest.builder.guild.GuildCreateBuilder import dev.kord.rest.builder.interaction.* import dev.kord.rest.builder.monetization.EntitlementsListRequestBuilder import dev.kord.rest.builder.user.CurrentUserModifyBuilder -import dev.kord.rest.json.request.TestEntitlementCreateRequest import dev.kord.rest.request.RestRequestException import dev.kord.rest.service.RestClient import io.github.oshai.kotlinlogging.KotlinLogging @@ -378,8 +373,7 @@ public class Kord( * * @throws RestRequestException if something went wrong during the request. */ - public suspend fun getSkus(): List = - rest.sku.listSkus(selfId).map { Sku(it, this) } + public suspend fun getSkus(): List = rest.sku.listSkus(selfId).map { Sku(it, this) } /** * Requests to get all [Entitlement]s for this application. @@ -391,58 +385,10 @@ public class Kord( builder: EntitlementsListRequestBuilder.() -> Unit = {}, ): Flow { contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } - - val request = EntitlementsListRequestBuilder() - .apply(builder) - .toRequest() - + val request = EntitlementsListRequestBuilder().apply(builder).toRequest() return strategy.supply(this).getEntitlements(selfId, request) } - /** - * Requests to create a new [test entitlement][Entitlement] to a [Sku] with the given [skuId] for an owner with the - * given [ownerId] and [ownerType]. Discord will act as though that owner has entitlement to your premium offering. - * - * The returned [Entitlement] will not contain [startsAt][Entitlement.startsAt] and [endsAt][Entitlement.endsAt], as - * it's valid in perpetuity. - * - * @throws RestRequestException if something went wrong during the request. - */ - public suspend fun createTestEntitlement( - skuId: Snowflake, - ownerId: Snowflake, - ownerType: EntitlementOwnerType, - ): Entitlement { - val response = - rest.entitlement.createTestEntitlement(selfId, TestEntitlementCreateRequest(skuId, ownerId, ownerType)) - val data = EntitlementData.from(response) - - return Entitlement(data, this) - } - - /** - * Requests to create a new [test entitlement][Entitlement] to a [Sku] with the given [skuId] for a given [user]. - * Discord will act as though that user has entitlement to your premium offering. - * - * The returned [Entitlement] will not contain [startsAt][Entitlement.startsAt] and [endsAt][Entitlement.endsAt], as - * it's valid in perpetuity. - * - * @throws RestRequestException if something went wrong during the request. - */ - public suspend fun createTestEntitlement(skuId: Snowflake, user: UserBehavior): Entitlement = - createTestEntitlement(skuId, user.id, EntitlementOwnerType.User) - - /** - * Requests to create a new [test entitlement][Entitlement] to a [Sku] with the given [skuId] for a given [guild]. - * Discord will act as though that guild has entitlement to your premium offering. - * - * The returned [Entitlement] will not contain [startsAt][Entitlement.startsAt] and [endsAt][Entitlement.endsAt], as - * it's valid in perpetuity. - * - * @throws RestRequestException if something went wrong during the request. - */ - public suspend fun createTestEntitlement(skuId: Snowflake, guild: GuildBehavior): Entitlement = - createTestEntitlement(skuId, guild.id, EntitlementOwnerType.Guild) public suspend fun getSticker(id: Snowflake): Sticker = defaultSupplier.getSticker(id) diff --git a/core/src/commonMain/kotlin/Unsafe.kt b/core/src/commonMain/kotlin/Unsafe.kt index 269d0676fb5..28e98182034 100644 --- a/core/src/commonMain/kotlin/Unsafe.kt +++ b/core/src/commonMain/kotlin/Unsafe.kt @@ -11,6 +11,8 @@ import dev.kord.core.behavior.channel.threads.ThreadChannelBehavior import dev.kord.core.behavior.channel.threads.ThreadParentChannelBehavior import dev.kord.core.behavior.interaction.ApplicationCommandInteractionBehavior import dev.kord.core.behavior.interaction.ComponentInteractionBehavior +import dev.kord.core.behavior.monetization.SkuBehavior +import dev.kord.core.behavior.monetization.SkuBehaviorImpl import dev.kord.rest.service.InteractionService /** @@ -46,6 +48,9 @@ public class Unsafe(private val kord: Kord) { ruleId: Snowflake, ): MentionSpamAutoModerationRuleBehavior = MentionSpamAutoModerationRuleBehaviorImpl(guildId, ruleId, kord) + public fun sku(skuId: Snowflake, applicationId: Snowflake = kord.selfId): SkuBehavior = + SkuBehaviorImpl(applicationId, skuId, kord) + public fun message(channelId: Snowflake, messageId: Snowflake): MessageBehavior = MessageBehavior(channelId = channelId, messageId = messageId, kord = kord) diff --git a/core/src/commonMain/kotlin/behavior/monetization/SkuBehavior.kt b/core/src/commonMain/kotlin/behavior/monetization/SkuBehavior.kt new file mode 100644 index 00000000000..a12a2218b49 --- /dev/null +++ b/core/src/commonMain/kotlin/behavior/monetization/SkuBehavior.kt @@ -0,0 +1,122 @@ +package dev.kord.core.behavior.monetization + +import dev.kord.common.entity.EntitlementOwnerType +import dev.kord.common.entity.Snowflake +import dev.kord.common.exception.RequestException +import dev.kord.core.Kord +import dev.kord.core.behavior.GuildBehavior +import dev.kord.core.behavior.UserBehavior +import dev.kord.core.cache.data.EntitlementData +import dev.kord.core.entity.Application +import dev.kord.core.entity.KordEntity +import dev.kord.core.entity.Strategizable +import dev.kord.core.entity.monetization.Entitlement +import dev.kord.core.entity.monetization.Sku +import dev.kord.core.entity.monetization.Subscription +import dev.kord.core.exception.EntityNotFoundException +import dev.kord.core.hash +import dev.kord.core.supplier.EntitySupplier +import dev.kord.core.supplier.EntitySupplyStrategy +import dev.kord.rest.builder.monetization.SkuSubscriptionsListRequestBuilder +import dev.kord.rest.json.request.TestEntitlementCreateRequest +import dev.kord.rest.request.RestRequestException +import kotlinx.coroutines.flow.Flow +import kotlin.contracts.InvocationKind.EXACTLY_ONCE +import kotlin.contracts.contract + +/** The behavior of an [Sku]. */ +public interface SkuBehavior : KordEntity, Strategizable { + + /** The ID of the [Application] this SKU is for. */ + public val applicationId: Snowflake + + /** + * Requests a [Subscription] containing this SKU by its [id][subscriptionId]. Returns `null` if it wasn't found. + * + * @throws RequestException if something went wrong during the request. + */ + public suspend fun getSubscriptionOrNull(subscriptionId: Snowflake): Subscription? = + supplier.getSubscriptionOrNull(this.id, subscriptionId) + + /** + * Requests a [Subscription] containing this SKU by its [id][subscriptionId]. + * + * @throws RequestException if something went wrong during the request. + * @throws EntityNotFoundException if the [Subscription] wasn't found. + */ + public suspend fun getSubscription(subscriptionId: Snowflake): Subscription = + supplier.getSubscription(this.id, subscriptionId) + + /** + * Requests to create a new [test entitlement][Entitlement] to this SKU for an owner with the given [ownerId] and + * [ownerType]. Discord will act as though that owner has entitlement to your premium offering. + * + * The returned [Entitlement] will not contain [startsAt][Entitlement.startsAt] and [endsAt][Entitlement.endsAt], as + * it's valid in perpetuity. + * + * @throws RestRequestException if something went wrong during the request. + */ + public suspend fun createTestEntitlement(ownerId: Snowflake, ownerType: EntitlementOwnerType): Entitlement { + val response = kord.rest.entitlement.createTestEntitlement( + applicationId, + TestEntitlementCreateRequest(this.id, ownerId, ownerType), + ) + return Entitlement(EntitlementData.from(response), kord) + } + + /** + * Requests to create a new [test entitlement][Entitlement] to this SKU for a given [user]. Discord will act as + * though that user has entitlement to your premium offering. + * + * The returned [Entitlement] will not contain [startsAt][Entitlement.startsAt] and [endsAt][Entitlement.endsAt], as + * it's valid in perpetuity. + * + * @throws RestRequestException if something went wrong during the request. + */ + public suspend fun createTestEntitlement(skuId: Snowflake, user: UserBehavior): Entitlement = + createTestEntitlement(user.id, EntitlementOwnerType.User) + + /** + * Requests to create a new [test entitlement][Entitlement] to this SKU for a given [guild]. Discord will act as + * though that guild has entitlement to your premium offering. + * + * The returned [Entitlement] will not contain [startsAt][Entitlement.startsAt] and [endsAt][Entitlement.endsAt], as + * it's valid in perpetuity. + * + * @throws RestRequestException if something went wrong during the request. + */ + public suspend fun createTestEntitlement(skuId: Snowflake, guild: GuildBehavior): Entitlement = + createTestEntitlement(guild.id, EntitlementOwnerType.Guild) + + override fun withStrategy(strategy: EntitySupplyStrategy<*>): SkuBehavior +} + +/** + * Requests to get all [Subscription]s containing this [Sku]. + * + * The returned flow is lazily executed, any [RequestException] will be thrown on + * [terminal operators](https://kotlinlang.org/docs/reference/coroutines/flow.html#terminal-flow-operators) instead. + */ +public inline fun SkuBehavior.getSubscriptions( + builder: SkuSubscriptionsListRequestBuilder.() -> Unit, +): Flow { + contract { callsInPlace(builder, EXACTLY_ONCE) } + val request = SkuSubscriptionsListRequestBuilder().apply(builder).toRequest() + return supplier.getSubscriptions(this.id, request) +} + +internal class SkuBehaviorImpl( + override val applicationId: Snowflake, + override val id: Snowflake, + override val kord: Kord, + override val supplier: EntitySupplier = kord.defaultSupplier, +) : SkuBehavior { + override fun withStrategy(strategy: EntitySupplyStrategy<*>) = + SkuBehaviorImpl(applicationId, id, kord, strategy.supply(kord)) + + override fun equals(other: Any?) = + other is SkuBehavior && this.id == other.id && this.applicationId == other.applicationId + + override fun hashCode() = hash(id, applicationId) + override fun toString() = "SkuBehavior(applicationId=$applicationId, id=$id, kord=$kord, supplier=$supplier)" +} diff --git a/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt b/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt index f764668812d..33220b80134 100644 --- a/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt +++ b/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt @@ -29,6 +29,7 @@ public suspend fun DataCache.registerKordData(): Unit = register( StickerData.description, AutoModerationRuleData.description, EntitlementData.description, + SubscriptionData.description, ) /** @@ -52,6 +53,7 @@ internal suspend fun DataCache.removeKordData() { query().remove() query().remove() query().remove() + query().remove() } /** diff --git a/core/src/commonMain/kotlin/cache/KordCache.kt b/core/src/commonMain/kotlin/cache/KordCache.kt index f43d36d7d34..b20740b0db9 100644 --- a/core/src/commonMain/kotlin/cache/KordCache.kt +++ b/core/src/commonMain/kotlin/cache/KordCache.kt @@ -123,6 +123,10 @@ public class KordCacheBuilder { public fun entitlements(generator: Generator): Unit = forDescription(EntitlementData.description, generator) + /** Configures the caching for [SubscriptionData]. */ + public fun subscriptions(generator: Generator): Unit = + forDescription(SubscriptionData.description, generator) + public fun build(): DataCache = DelegatingDataCache(EntrySupplier.invoke { cache, description -> val generator = descriptionGenerators[description] ?: defaultGenerator generator(cache, description) diff --git a/core/src/commonMain/kotlin/cache/data/SubscriptionData.kt b/core/src/commonMain/kotlin/cache/data/SubscriptionData.kt new file mode 100644 index 00000000000..0d05e230344 --- /dev/null +++ b/core/src/commonMain/kotlin/cache/data/SubscriptionData.kt @@ -0,0 +1,41 @@ +package dev.kord.core.cache.data + +import dev.kord.cache.api.data.DataDescription +import dev.kord.cache.api.data.description +import dev.kord.common.entity.DiscordSubscription +import dev.kord.common.entity.Snowflake +import dev.kord.common.entity.SubscriptionStatus +import dev.kord.common.entity.optional.Optional +import kotlinx.datetime.Instant +import kotlinx.serialization.Serializable + +@Serializable +public data class SubscriptionData( + val id: Snowflake, + val userId: Snowflake, + val skuIds: List, + val entitlementIds: List, + val currentPeriodStart: Instant, + val currentPeriodEnd: Instant, + val status: SubscriptionStatus, + val canceledAt: Instant?, + val country: Optional = Optional.Missing(), +) { + public companion object { + public val description: DataDescription = description(SubscriptionData::id) + + public fun from(subscription: DiscordSubscription): SubscriptionData = with(subscription) { + SubscriptionData( + id = id, + userId = userId, + skuIds = skuIds, + entitlementIds = entitlementIds, + currentPeriodStart = currentPeriodStart, + currentPeriodEnd = currentPeriodEnd, + status = status, + canceledAt = canceledAt, + country = country, + ) + } + } +} diff --git a/core/src/commonMain/kotlin/cache/data/UserData.kt b/core/src/commonMain/kotlin/cache/data/UserData.kt index 890ce30fa92..82c5830cfac 100644 --- a/core/src/commonMain/kotlin/cache/data/UserData.kt +++ b/core/src/commonMain/kotlin/cache/data/UserData.kt @@ -34,6 +34,7 @@ public data class UserData( link(UserData::id to VoiceStateData::userId) link(UserData::id to PresenceData::userId) link(UserData::id to EntitlementData::nullableUserId) + link(UserData::id to SubscriptionData::userId) } public fun from(entity: DiscordUser): UserData = with(entity) { diff --git a/core/src/commonMain/kotlin/entity/monetization/Sku.kt b/core/src/commonMain/kotlin/entity/monetization/Sku.kt index 5ff2619d321..9863f2a195c 100644 --- a/core/src/commonMain/kotlin/entity/monetization/Sku.kt +++ b/core/src/commonMain/kotlin/entity/monetization/Sku.kt @@ -5,11 +5,13 @@ import dev.kord.common.entity.SkuFlags import dev.kord.common.entity.SkuType import dev.kord.common.entity.Snowflake import dev.kord.core.Kord +import dev.kord.core.behavior.monetization.SkuBehavior import dev.kord.core.entity.Application import dev.kord.core.entity.Guild -import dev.kord.core.entity.KordEntity import dev.kord.core.entity.User import dev.kord.core.hash +import dev.kord.core.supplier.EntitySupplier +import dev.kord.core.supplier.EntitySupplyStrategy /** * An instance of an [SKU](https://discord.com/developers/docs/resources/sku). @@ -20,7 +22,8 @@ import dev.kord.core.hash public class Sku( public val data: DiscordSku, override val kord: Kord, -) : KordEntity { + override val supplier: EntitySupplier = kord.defaultSupplier, +) : SkuBehavior { override val id: Snowflake get() = data.id @@ -29,10 +32,7 @@ public class Sku( */ public val type: SkuType get() = data.type - /** - * The ID of the [Application] this SKU is for. - */ - public val applicationId: Snowflake get() = data.applicationId + override val applicationId: Snowflake get() = data.applicationId /** * The customer-facing name of this premium offering. @@ -49,8 +49,10 @@ public class Sku( */ public val flags: SkuFlags get() = data.flags + override fun withStrategy(strategy: EntitySupplyStrategy<*>): Sku = Sku(data, kord, strategy.supply(kord)) + override fun equals(other: Any?): Boolean = - other is Sku && this.id == other.id && this.applicationId == other.applicationId + other is SkuBehavior && this.id == other.id && this.applicationId == other.applicationId override fun hashCode(): Int = hash(id, applicationId) diff --git a/core/src/commonMain/kotlin/entity/monetization/Subscription.kt b/core/src/commonMain/kotlin/entity/monetization/Subscription.kt new file mode 100644 index 00000000000..18b55a7c70c --- /dev/null +++ b/core/src/commonMain/kotlin/entity/monetization/Subscription.kt @@ -0,0 +1,65 @@ +package dev.kord.core.entity.monetization + +import dev.kord.common.entity.Snowflake +import dev.kord.common.entity.SubscriptionStatus +import dev.kord.core.Kord +import dev.kord.core.behavior.UserBehavior +import dev.kord.core.cache.data.SubscriptionData +import dev.kord.core.entity.KordEntity +import dev.kord.core.entity.User +import dev.kord.core.hash +import kotlinx.datetime.Instant + +/** + * An instance of a [Subscription](https://discord.com/developers/docs/resources/subscription). + * + * Subscriptions represent a [User] making recurring payments for at least one [Sku] over an ongoing period. Successful + * payments grant the [User] access to entitlements associated with the [Sku]. + */ +public class Subscription( + public val data: SubscriptionData, + override val kord: Kord, +) : KordEntity { + override val id: Snowflake get() = data.id + + /** The ID of the [User] who is subscribed. */ + public val userId: Snowflake get() = data.userId + + /** The behavior of the [User] who is subscribed. */ + public val user: UserBehavior get() = UserBehavior(userId, kord) + + /** The list of [Sku]s subscribed to. */ + public val skuIds: List get() = data.skuIds + + /** The list of [Entitlement]s granted for this subscription. */ + public val entitlementIds: List get() = data.entitlementIds + + /** The start date of the current subscription period. */ + public val currentPeriodStart: Instant get() = data.currentPeriodStart + + /** The end date of the current subscription period. */ + public val currentPeriodEnd: Instant get() = data.currentPeriodEnd + + /** The current status of this subscription. */ + public val status: SubscriptionStatus get() = data.status + + /** When this subscription was canceled. */ + public val canceledAt: Instant? get() = data.canceledAt + + /** + * The ISO3166-1 alpha-2 country code of the payment source used to purchase this subscription. + * + * Missing unless queried with a private OAuth scope. + */ + public val country: String? get() = data.country.value + + /** The start date of this subscription. */ + public val startsAt: Instant get() = id.timestamp + + override fun equals(other: Any?): Boolean = + other is Subscription && this.id == other.id && this.userId == other.userId + + override fun hashCode(): Int = hash(id, userId) + + override fun toString(): String = "Subscription(data=$data, kord=$kord)" +} diff --git a/core/src/commonMain/kotlin/event/monetization/SubscriptionEvents.kt b/core/src/commonMain/kotlin/event/monetization/SubscriptionEvents.kt new file mode 100644 index 00000000000..73263a27325 --- /dev/null +++ b/core/src/commonMain/kotlin/event/monetization/SubscriptionEvents.kt @@ -0,0 +1,52 @@ +package dev.kord.core.event.monetization + +import dev.kord.common.entity.SubscriptionStatus.Active +import dev.kord.common.entity.SubscriptionStatus.Inactive +import dev.kord.core.Kord +import dev.kord.core.entity.monetization.Entitlement +import dev.kord.core.entity.monetization.Subscription +import dev.kord.core.event.Event + +/** + * An [Event] that is sent when a [Subscription] for a Premium App is created. + * + * A [Subscription]'s [status][Subscription.status] can be either [Inactive] or [Active] when this event is received. + * You will receive subsequent [SubscriptionUpdateEvent]s if the [status][Subscription.status] is updated to [Active]. + * As a best practice, you should not grant any perks to users until the [Entitlement]s are created. + */ +public class SubscriptionCreateEvent( + /** The [Subscription] that was created. */ + public val subscription: Subscription, + override val kord: Kord, + override val shard: Int, + override val customContext: Any?, +) : Event { + override fun toString(): String = + "SubscriptionCreateEvent(subscription=$subscription, kord=$kord, shard=$shard, customContext=$customContext)" +} + +/** An [Event] that is sent when a [Subscription] for a Premium App has been updated. */ +public class SubscriptionUpdateEvent( + /** The [Subscription] that was updated. */ + public val subscription: Subscription, + /** The [Subscription] as found in [cache][Kord.cache] before the update. */ + public val old: Subscription?, + override val kord: Kord, + override val shard: Int, + override val customContext: Any?, +) : Event { + override fun toString(): String = "SubscriptionUpdateEvent(subscription=$subscription, old=$old, kord=$kord, " + + "shard=$shard, customContext=$customContext)" +} + +/** An [Event] that is sent when a [Subscription] for a Premium App has been deleted. */ +public class SubscriptionDeleteEvent( + /** The [Subscription] that was deleted. */ + public val subscription: Subscription, + override val kord: Kord, + override val shard: Int, + override val customContext: Any?, +) : Event { + override fun toString(): String = + "SubscriptionDeleteEvent(subscription=$subscription, kord=$kord, shard=$shard, customContext=$customContext)" +} diff --git a/core/src/commonMain/kotlin/exception/EntityNotFoundException.kt b/core/src/commonMain/kotlin/exception/EntityNotFoundException.kt index a145d0956a2..86ca26572cf 100644 --- a/core/src/commonMain/kotlin/exception/EntityNotFoundException.kt +++ b/core/src/commonMain/kotlin/exception/EntityNotFoundException.kt @@ -104,5 +104,8 @@ public class EntityNotFoundException : Exception { public inline fun autoModerationRuleNotFound(guildId: Snowflake, ruleId: Snowflake): Nothing = guildEntityNotFound("Auto Moderation Rule", guildId, ruleId) + + public inline fun subscriptionNotFound(skuId: Snowflake, subscriptionId: Snowflake): Nothing = + throw EntityNotFoundException("Subscription with id $subscriptionId for SKU with id $skuId was not found.") } } diff --git a/core/src/commonMain/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt b/core/src/commonMain/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt index 48ee6801a7f..6af30d04b7b 100644 --- a/core/src/commonMain/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt +++ b/core/src/commonMain/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt @@ -42,6 +42,7 @@ public class DefaultGatewayEventInterceptor @KordPreview public constructor( InteractionEventHandler(), LifeCycleEventHandler(), MessageEventHandler(), + SubscriptionEventHandler(), ThreadEventHandler(), UnknownEventHandler(), UserEventHandler(), diff --git a/core/src/commonMain/kotlin/gateway/handler/SubscriptionEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/SubscriptionEventHandler.kt new file mode 100644 index 00000000000..897295161fa --- /dev/null +++ b/core/src/commonMain/kotlin/gateway/handler/SubscriptionEventHandler.kt @@ -0,0 +1,68 @@ +package dev.kord.core.gateway.handler + +import dev.kord.cache.api.put +import dev.kord.cache.api.query +import dev.kord.cache.api.remove +import dev.kord.common.entity.DiscordSubscription +import dev.kord.core.Kord +import dev.kord.core.cache.data.SubscriptionData +import dev.kord.core.cache.idEq +import dev.kord.core.entity.monetization.Subscription +import dev.kord.core.event.monetization.SubscriptionCreateEvent +import dev.kord.core.event.monetization.SubscriptionDeleteEvent +import dev.kord.core.event.monetization.SubscriptionUpdateEvent +import dev.kord.gateway.Event +import dev.kord.gateway.SubscriptionCreate +import dev.kord.gateway.SubscriptionDelete +import dev.kord.gateway.SubscriptionUpdate + +internal class SubscriptionEventHandler : BaseGatewayEventHandler() { + + override suspend fun handle( + event: Event, + shard: Int, + kord: Kord, + context: LazyContext?, + ): dev.kord.core.event.Event? = when (event) { + is SubscriptionCreate -> SubscriptionCreateEvent( + subscription = handleSubscription(event.subscription, kord), + kord = kord, + shard = shard, + customContext = context?.get(), + ) + is SubscriptionUpdate -> SubscriptionUpdateEvent( + old = kord.cache + .query { + idEq(SubscriptionData::id, event.subscription.id) + idEq(SubscriptionData::userId, event.subscription.userId) + } + .singleOrNull() + ?.let { Subscription(it, kord) }, + subscription = handleSubscription(event.subscription, kord), + kord = kord, + shard = shard, + customContext = context?.get(), + ) + is SubscriptionDelete -> SubscriptionDeleteEvent( + subscription = handleDeletedSubscription(event.subscription, kord), + kord = kord, + shard = shard, + customContext = context?.get(), + ) + else -> null + } + + private suspend fun handleDeletedSubscription(subscription: DiscordSubscription, kord: Kord): Subscription { + kord.cache.remove { + idEq(SubscriptionData::id, subscription.id) + idEq(SubscriptionData::userId, subscription.userId) + } + return Subscription(SubscriptionData.from(subscription), kord) + } + + private suspend fun handleSubscription(subscription: DiscordSubscription, kord: Kord): Subscription { + val data = SubscriptionData.from(subscription) + kord.cache.put(data) + return Subscription(data, kord) + } +} diff --git a/core/src/commonMain/kotlin/supplier/CacheEntitySupplier.kt b/core/src/commonMain/kotlin/supplier/CacheEntitySupplier.kt index 4c6fc352ec6..31fbbb86033 100644 --- a/core/src/commonMain/kotlin/supplier/CacheEntitySupplier.kt +++ b/core/src/commonMain/kotlin/supplier/CacheEntitySupplier.kt @@ -23,9 +23,11 @@ import dev.kord.core.entity.channel.thread.ThreadChannel import dev.kord.core.entity.channel.thread.ThreadMember import dev.kord.core.entity.interaction.followup.FollowupMessage import dev.kord.core.entity.monetization.Entitlement +import dev.kord.core.entity.monetization.Subscription import dev.kord.core.exception.EntityNotFoundException import dev.kord.gateway.Gateway import dev.kord.rest.json.request.EntitlementsListRequest +import dev.kord.rest.json.request.SkuSubscriptionsListRequest import dev.kord.rest.route.Position import kotlinx.coroutines.flow.* import kotlinx.datetime.Clock @@ -642,6 +644,34 @@ public class CacheEntitySupplier(private val kord: Kord) : EntitySupplier { .limit(request.limit) } + override fun getSubscriptions(skuId: Snowflake, request: SkuSubscriptionsListRequest): Flow { + checkLimit(request.limit) + return cache + .query { + SubscriptionData::skuIds predicate { skuIds -> skuId in skuIds } + + when (val pos = request.position) { + null -> {} + is Position.Before -> idLt(SubscriptionData::id, pos.value) + is Position.After -> idGt(SubscriptionData::id, pos.value) + } + + request.userId?.let { idEq(SubscriptionData::userId, it) } + } + .asFlow() + .map { Subscription(it, kord) } + .limit(request.limit) + } + + override suspend fun getSubscriptionOrNull(skuId: Snowflake, subscriptionId: Snowflake): Subscription? = + cache + .query { + idEq(SubscriptionData::id, subscriptionId) + SubscriptionData::skuIds predicate { skuIds -> skuId in skuIds } + } + .singleOrNull() + ?.let { Subscription(it, kord) } + override fun toString(): String = "CacheEntitySupplier(cache=$cache)" } diff --git a/core/src/commonMain/kotlin/supplier/EntitySupplier.kt b/core/src/commonMain/kotlin/supplier/EntitySupplier.kt index b566f3e6945..4c45962e56b 100644 --- a/core/src/commonMain/kotlin/supplier/EntitySupplier.kt +++ b/core/src/commonMain/kotlin/supplier/EntitySupplier.kt @@ -16,8 +16,11 @@ import dev.kord.core.entity.channel.thread.ThreadChannel import dev.kord.core.entity.channel.thread.ThreadMember import dev.kord.core.entity.interaction.followup.FollowupMessage import dev.kord.core.entity.monetization.Entitlement +import dev.kord.core.entity.monetization.Sku +import dev.kord.core.entity.monetization.Subscription import dev.kord.core.exception.EntityNotFoundException import dev.kord.rest.json.request.EntitlementsListRequest +import dev.kord.rest.json.request.SkuSubscriptionsListRequest import kotlinx.coroutines.flow.Flow import kotlinx.datetime.Instant @@ -652,6 +655,31 @@ public interface EntitySupplier { * [terminal operators](https://kotlinlang.org/docs/reference/coroutines/flow.html#terminal-flow-operators) instead. */ public fun getEntitlements(applicationId: Snowflake, request: EntitlementsListRequest): Flow + + /** + * Requests to get all [Subscription]s containing the [Sku] with the given [skuId]. + * + * The returned flow is lazily executed, any [RequestException] will be thrown on + * [terminal operators](https://kotlinlang.org/docs/reference/coroutines/flow.html#terminal-flow-operators) instead. + */ + public fun getSubscriptions(skuId: Snowflake, request: SkuSubscriptionsListRequest): Flow + + /** + * Requests a [Subscription] by its [id][subscriptionId]. Returns `null` if it wasn't found. + * + * @throws RequestException if something went wrong during the request. + */ + public suspend fun getSubscriptionOrNull(skuId: Snowflake, subscriptionId: Snowflake): Subscription? + + /** + * Requests a [Subscription] by its [id][subscriptionId]. + * + * @throws RequestException if something went wrong during the request. + * @throws EntityNotFoundException if the [Subscription] wasn't found. + */ + public suspend fun getSubscription(skuId: Snowflake, subscriptionId: Snowflake): Subscription = + getSubscriptionOrNull(skuId, subscriptionId) + ?: EntityNotFoundException.subscriptionNotFound(skuId, subscriptionId) } diff --git a/core/src/commonMain/kotlin/supplier/FallbackEntitySupplier.kt b/core/src/commonMain/kotlin/supplier/FallbackEntitySupplier.kt index 0e26b77665d..9f0bf9d3737 100644 --- a/core/src/commonMain/kotlin/supplier/FallbackEntitySupplier.kt +++ b/core/src/commonMain/kotlin/supplier/FallbackEntitySupplier.kt @@ -12,8 +12,10 @@ import dev.kord.core.entity.channel.thread.ThreadChannel import dev.kord.core.entity.channel.thread.ThreadMember import dev.kord.core.entity.interaction.followup.FollowupMessage import dev.kord.core.entity.monetization.Entitlement +import dev.kord.core.entity.monetization.Subscription import dev.kord.core.switchIfEmpty import dev.kord.rest.json.request.EntitlementsListRequest +import dev.kord.rest.json.request.SkuSubscriptionsListRequest import kotlinx.coroutines.flow.Flow import kotlinx.datetime.Instant @@ -282,5 +284,11 @@ private class FallbackEntitySupplier(val first: EntitySupplier, val second: Enti override fun getEntitlements(applicationId: Snowflake, request: EntitlementsListRequest): Flow = first.getEntitlements(applicationId, request).switchIfEmpty(second.getEntitlements(applicationId, request)) + override fun getSubscriptions(skuId: Snowflake, request: SkuSubscriptionsListRequest): Flow = + first.getSubscriptions(skuId, request).switchIfEmpty(second.getSubscriptions(skuId, request)) + + override suspend fun getSubscriptionOrNull(skuId: Snowflake, subscriptionId: Snowflake): Subscription? = + first.getSubscriptionOrNull(skuId, subscriptionId) ?: second.getSubscriptionOrNull(skuId, subscriptionId) + override fun toString(): String = "FallbackEntitySupplier(first=$first, second=$second)" } diff --git a/core/src/commonMain/kotlin/supplier/RestEntitySupplier.kt b/core/src/commonMain/kotlin/supplier/RestEntitySupplier.kt index 4d935fe011e..a57432799bc 100644 --- a/core/src/commonMain/kotlin/supplier/RestEntitySupplier.kt +++ b/core/src/commonMain/kotlin/supplier/RestEntitySupplier.kt @@ -2,6 +2,7 @@ package dev.kord.core.supplier import dev.kord.common.entity.DiscordAuditLogEntry import dev.kord.common.entity.DiscordEntitlement +import dev.kord.common.entity.DiscordSubscription import dev.kord.common.entity.Snowflake import dev.kord.common.entity.optional.OptionalSnowflake import dev.kord.common.entity.optional.optionalSnowflake @@ -18,6 +19,7 @@ import dev.kord.core.entity.channel.thread.ThreadChannel import dev.kord.core.entity.channel.thread.ThreadMember import dev.kord.core.entity.interaction.followup.FollowupMessage import dev.kord.core.entity.monetization.Entitlement +import dev.kord.core.entity.monetization.Subscription import dev.kord.core.exception.EntityNotFoundException import dev.kord.rest.builder.auditlog.AuditLogGetRequestBuilder import dev.kord.rest.json.request.* @@ -58,6 +60,7 @@ public class RestEntitySupplier(public val kord: Kord) : EntitySupplier { private inline val invite get() = kord.rest.invite private inline val stageInstance get() = kord.rest.stageInstance private inline val sticker get() = kord.rest.sticker + private inline val subscription get() = kord.rest.subscription private inline val user get() = kord.rest.user private inline val voice get() = kord.rest.voice private inline val webhook get() = kord.rest.webhook @@ -661,6 +664,29 @@ public class RestEntitySupplier(public val kord: Kord) : EntitySupplier { } }.map { entitlement -> Entitlement(data = EntitlementData.from(entitlement), kord) } + // maxBatchSize: see https://discord.com/developers/docs/resources/subscription#list-sku-subscriptions + override fun getSubscriptions( + skuId: Snowflake, + request: SkuSubscriptionsListRequest, + ): Flow = limitedPagination(request.limit, maxBatchSize = 100) { batchSize -> + val req: suspend (Position.BeforeOrAfter) -> List = { position -> + subscription.listSkuSubscriptions(skuId, request.copy(position = position, limit = batchSize)) + } + when (val start = request.position) { + null, is Position.After -> + paginateForwards(batchSize, start = start?.value ?: Snowflake.min, idSelector = { it.id }, req) + + is Position.Before -> paginateBackwards(batchSize, start.value, idSelector = { it.id }, req) + } + }.map { subscription -> Subscription(data = SubscriptionData.from(subscription), kord) } + + override suspend fun getSubscriptionOrNull(skuId: Snowflake, subscriptionId: Snowflake): Subscription? = + catchNotFound { + val response = subscription.getSkuSubscription(skuId, subscriptionId) + val data = SubscriptionData.from(response) + Subscription(data, kord) + } + override fun toString(): String = "RestEntitySupplier(rest=${kord.rest})" } diff --git a/core/src/commonMain/kotlin/supplier/StoreEntitySupplier.kt b/core/src/commonMain/kotlin/supplier/StoreEntitySupplier.kt index b5b2ec0054b..2da0f5d0752 100644 --- a/core/src/commonMain/kotlin/supplier/StoreEntitySupplier.kt +++ b/core/src/commonMain/kotlin/supplier/StoreEntitySupplier.kt @@ -14,7 +14,9 @@ import dev.kord.core.entity.channel.thread.ThreadChannel import dev.kord.core.entity.channel.thread.ThreadMember import dev.kord.core.entity.interaction.followup.FollowupMessage import dev.kord.core.entity.monetization.Entitlement +import dev.kord.core.entity.monetization.Subscription import dev.kord.rest.json.request.EntitlementsListRequest +import dev.kord.rest.json.request.SkuSubscriptionsListRequest import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.onEach import kotlinx.datetime.Instant @@ -314,6 +316,12 @@ public class StoreEntitySupplier( override fun getEntitlements(applicationId: Snowflake, request: EntitlementsListRequest): Flow = storeOnEach(supplier.getEntitlements(applicationId, request)) { it.data } + override fun getSubscriptions(skuId: Snowflake, request: SkuSubscriptionsListRequest): Flow = + storeOnEach(supplier.getSubscriptions(skuId, request)) { it.data } + + override suspend fun getSubscriptionOrNull(skuId: Snowflake, subscriptionId: Snowflake): Subscription? = + storeAndReturn(supplier.getSubscriptionOrNull(skuId, subscriptionId)) { it.data } + private inline fun storeOnEach(source: Flow, crossinline transform: (T) -> R): Flow { return source.onEach { fetchedEntity ->