Skip to content

Commit

Permalink
Corrections for #743 (#781)
Browse files Browse the repository at this point in the history
* rename GuildFeature.CreatorMonetizableProvision to
  GuildFeature.CreatorMonetizableProvisional

* deprecate GuildFeature.MonetizationEnabled, see
  discord/discord-api-docs#5724 (comment)

* add @SerialName for DiscordRoleTags.botId

* add RoleTags.isLinkedRole

* fix DiscordMessage.roleSubscriptionData nullability

* fix KDocs

see discord/discord-api-docs#5724 and
discord/discord-api-docs#5828

Co-authored-by: NoComment <67918617+NoComment1105@users.noreply.github.com>
  • Loading branch information
lukellmann and NoComment1105 committed Mar 5, 2023
1 parent 41c9560 commit a788bfc
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 26 deletions.
4 changes: 2 additions & 2 deletions common/api/common.api
Original file line number Diff line number Diff line change
Expand Up @@ -6208,8 +6208,8 @@ public final class dev/kord/common/entity/GuildFeature$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public final class dev/kord/common/entity/GuildFeature$CreatorMonetizableProvision : dev/kord/common/entity/GuildFeature {
public static final field INSTANCE Ldev/kord/common/entity/GuildFeature$CreatorMonetizableProvision;
public final class dev/kord/common/entity/GuildFeature$CreatorMonetizableProvisional : dev/kord/common/entity/GuildFeature {
public static final field INSTANCE Ldev/kord/common/entity/GuildFeature$CreatorMonetizableProvisional;
}

public final class dev/kord/common/entity/GuildFeature$CreatorStorePage : dev/kord/common/entity/GuildFeature {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import kotlin.Deprecated
import kotlin.DeprecationLevel
import kotlin.Int
import kotlin.LazyThreadSafetyMode.PUBLICATION
import kotlin.ReplaceWith
import kotlin.String
import kotlin.Suppress
import kotlin.collections.List
Expand Down Expand Up @@ -84,7 +85,7 @@ public sealed class GuildFeature(
/**
* Guild has enabled monetization.
*/
public object CreatorMonetizableProvision : GuildFeature("CREATOR_MONETIZABLE_PROVISIONAL")
public object CreatorMonetizableProvisional : GuildFeature("CREATOR_MONETIZABLE_PROVISIONAL")

/**
* Guild has enabled the role subscription promo page.
Expand Down Expand Up @@ -121,11 +122,6 @@ public sealed class GuildFeature(
*/
public object MemberVerificationGateEnabled : GuildFeature("MEMBER_VERIFICATION_GATE_ENABLED")

/**
* Guild has enabled monetization.
*/
public object MonetizationEnabled : GuildFeature("MONETIZATION_ENABLED")

/**
* Guild has increased custom sticker slots.
*/
Expand Down Expand Up @@ -199,6 +195,16 @@ public sealed class GuildFeature(
)
public object Commerce : GuildFeature("COMMERCE")

/**
* Guild has enabled monetization.
*/
@Deprecated(
message = "Replaced by CreatorMonetizableProvisional.",
replaceWith = ReplaceWith(expression = "GuildFeature.CreatorMonetizableProvisional", imports
= arrayOf("dev.kord.common.entitiy.GuildFeature")),
)
public object MonetizationEnabled : GuildFeature("MONETIZATION_ENABLED")

/**
* Guild has access to create private threads
*/
Expand Down Expand Up @@ -244,15 +250,15 @@ public sealed class GuildFeature(
"BANNER" -> Banner
"COMMERCE" -> @Suppress("DEPRECATION_ERROR") Commerce
"COMMUNITY" -> Community
"CREATOR_MONETIZABLE_PROVISIONAL" -> CreatorMonetizableProvision
"CREATOR_MONETIZABLE_PROVISIONAL" -> CreatorMonetizableProvisional
"CREATOR_STORE_PAGE" -> CreatorStorePage
"DEVELOPER_SUPPORT_SERVER" -> DeveloperSupportServer
"DISCOVERABLE" -> Discoverable
"FEATURABLE" -> Featurable
"INVITES_DISABLED" -> InvitesDisabled
"INVITE_SPLASH" -> InviteSplash
"MEMBER_VERIFICATION_GATE_ENABLED" -> MemberVerificationGateEnabled
"MONETIZATION_ENABLED" -> MonetizationEnabled
"MONETIZATION_ENABLED" -> @Suppress("DEPRECATION") MonetizationEnabled
"MORE_STICKERS" -> MoreStickers
"NEWS" -> News
"PARTNERED" -> Partnered
Expand Down Expand Up @@ -285,15 +291,15 @@ public sealed class GuildFeature(
Banner,
@Suppress("DEPRECATION_ERROR") Commerce,
Community,
CreatorMonetizableProvision,
CreatorMonetizableProvisional,
CreatorStorePage,
DeveloperSupportServer,
Discoverable,
Featurable,
InvitesDisabled,
InviteSplash,
MemberVerificationGateEnabled,
MonetizationEnabled,
@Suppress("DEPRECATION") MonetizationEnabled,
MoreStickers,
News,
Partnered,
Expand Down
19 changes: 13 additions & 6 deletions common/src/main/kotlin/entity/DiscordGuild.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"receives community updates.",
),
Entry(
"CreatorMonetizableProvision", stringValue = "CREATOR_MONETIZABLE_PROVISIONAL",
"CreatorMonetizableProvisional", stringValue = "CREATOR_MONETIZABLE_PROVISIONAL",
kDoc = "Guild has enabled monetization."
),
Entry(
Expand Down Expand Up @@ -115,7 +115,6 @@
"MemberVerificationGateEnabled", stringValue = "MEMBER_VERIFICATION_GATE_ENABLED",
kDoc = "Guild has enabled Membership Screening.",
),
Entry("MonetizationEnabled", stringValue = "MONETIZATION_ENABLED", kDoc = "Guild has enabled monetization."),
Entry("MoreStickers", stringValue = "MORE_STICKERS", kDoc = "Guild has increased custom sticker slots."),
Entry("News", stringValue = "NEWS", kDoc = "Guild has access to create announcement channels."),
Entry("Partnered", stringValue = "PARTNERED", kDoc = "Guild is partnered."),
Expand Down Expand Up @@ -155,6 +154,14 @@
" for more information.",
deprecationLevel = HIDDEN,
),
Entry(
"MonetizationEnabled", stringValue = "MONETIZATION_ENABLED", kDoc = "Guild has enabled monetization.",
deprecationMessage = "Replaced by CreatorMonetizableProvisional.", deprecationLevel = WARNING,
replaceWith = ReplaceWith(
"GuildFeature.CreatorMonetizableProvisional",
imports = ["dev.kord.common.entitiy.GuildFeature"],
),
),
Entry(
"PrivateThreads", stringValue = "PRIVATE_THREADS", kDoc = "Guild has access to create private threads",
deprecationMessage = "Creating a private thread no longer requires the server to be boosted.",
Expand Down Expand Up @@ -390,16 +397,16 @@ public enum class SystemChannelFlag(public val code: Int) {
/** Suppress server boost notifications. **/
SuppressPremiumSubscriptions(1.shl(1)),

/** Suppress guild reminder notifications **/
/** Hide server setup tips. **/
SuppressGuildReminderNotifications(1.shl(2)),

/** Suppress join notification replies **/
/** Hide member join sticker reply buttons. **/
SuppressJoinNotificationReplies(1.shl(3)),

/** Suppress role subscription notifications **/
/** Suppress role subscription purchase and renewal notifications. **/
SuppressRoleSubscriptionPurchaseNotifications(1.shl(4)),

/** Suppress role subscription notification replies **/
/** Hide role subscription sticker reply buttons. **/
SuppressRoleSubscriptionPurchaseNotificationReplies(1.shl(5)),
}

Expand Down
2 changes: 1 addition & 1 deletion common/src/main/kotlin/entity/DiscordMessage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public data class DiscordMessage(
@SerialName("referenced_message")
val referencedMessage: Optional<DiscordMessage?> = Optional.Missing(),
@SerialName("role_subscription_data")
val roleSubscriptionData: Optional<RoleSubscription?> = Optional.Missing(),
val roleSubscriptionData: Optional<RoleSubscription> = Optional.Missing(),

/*
* don't trust the docs:
Expand Down
1 change: 1 addition & 0 deletions common/src/main/kotlin/entity/DiscordRole.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public data class DiscordRole(

@Serializable
public data class DiscordRoleTags(
@SerialName("bot_id")
val botId: OptionalSnowflake = OptionalSnowflake.Missing,
@SerialName("integration_id")
val integrationId: OptionalSnowflake = OptionalSnowflake.Missing,
Expand Down
1 change: 1 addition & 0 deletions core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -6848,6 +6848,7 @@ public final class dev/kord/core/entity/RoleTags : dev/kord/core/KordObject, dev
public final fun getSubscriptionListingId ()Ldev/kord/common/entity/Snowflake;
public fun getSupplier ()Ldev/kord/core/supplier/EntitySupplier;
public final fun isAvailableForPurchase ()Z
public final fun isLinkedRole ()Z
public final fun isPremiumRole ()Z
public fun withStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)Ldev/kord/core/entity/Strategizable;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/kotlin/cache/data/MessageData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public data class MessageData(
val referencedMessage: Optional<MessageData?> = Optional.Missing(),
val interaction: Optional<MessageInteractionData> = Optional.Missing(),
val components: Optional<List<ComponentData>> = Optional.Missing(),
val roleSubscriptionData: Optional<RoleSubscription?> = Optional.Missing(),
val roleSubscriptionData: Optional<RoleSubscription> = Optional.Missing(),
) {

public fun plus(selfId: Snowflake, reaction: MessageReactionAddData): MessageData {
Expand Down
5 changes: 2 additions & 3 deletions core/src/main/kotlin/entity/Message.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.kord.core.entity

import dev.kord.common.entity.*
import dev.kord.common.entity.MessageType.RoleSubscriptionPurchase
import dev.kord.common.entity.optional.mapNullable
import dev.kord.common.entity.optional.orEmpty
import dev.kord.common.entity.optional.unwrap
Expand Down Expand Up @@ -285,9 +286,7 @@ public class Message(
*/
public val webhookId: Snowflake? get() = data.webhookId.value

/**
* The [RoleSubscription] data that triggered this message.
*/
/** The data of the [RoleSubscription] purchase or renewal that prompted this [RoleSubscriptionPurchase] message. */
public val roleSubscriptionData: RoleSubscription? get() = data.roleSubscriptionData.value

/** The [ActionRowComponent]s of this message. */
Expand Down
9 changes: 6 additions & 3 deletions core/src/main/kotlin/entity/RoleTags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public class RoleTags(
public val botId: Snowflake? get() = data.botId.value

/**
* The ID of the of the [Integration] this role belongs to.
* The ID of the [Integration] this role belongs to.
*/
public val integrationId: Snowflake? get() = data.integrationId.value

/**
* Whether this is the guild's premium subscriber role.
* Whether this is the guild's Booster role.
*/
public val isPremiumRole: Boolean get() = data.premiumSubscriber

Expand All @@ -39,10 +39,13 @@ public class RoleTags(
public val subscriptionListingId: Snowflake? get() = data.subscriptionListingId.value

/**
* Whether this role is avaialble for purchase.
* Whether this role is available for purchase.
*/
public val isAvailableForPurchase: Boolean get() = data.availableForPurchase

/** Whether this role is a guild's linked role. */
public val isLinkedRole: Boolean get() = data.guildConnections

/**
* The guild behavior this tag belongs to.
*/
Expand Down

0 comments on commit a788bfc

Please sign in to comment.