Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Role subscriptions #743

Merged
merged 7 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 77 additions & 10 deletions common/api/common.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ public sealed class GuildFeature(
*/
public object Community : GuildFeature("COMMUNITY")

/**
* Guild has enabled monetization.
*/
public object CreatorMonetizableProvision : GuildFeature("CREATOR_MONETIZABLE_PROVISIONAL")

/**
* Guild has enabled the role subscription promo page.
*/
public object CreatorStorePage : GuildFeature("CREATOR_STORE_PAGE")

/**
* Guild has been set as a support server on the App Directory.
*/
Expand Down Expand Up @@ -141,6 +151,17 @@ public sealed class GuildFeature(
*/
public object RoleIcons : GuildFeature("ROLE_ICONS")

/**
* Guild has role subscriptions that can be purchased.
*/
public object RoleSubscriptionsAvailableForPurchase :
GuildFeature("ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE")

/**
* Guild has enabled role subscriptions.
*/
public object RoleSubscriptionsEnabled : GuildFeature("ROLE_SUBSCRIPTIONS_ENABLED")

/**
* Guild has enabled ticketed events.
*/
Expand Down Expand Up @@ -223,6 +244,8 @@ public sealed class GuildFeature(
"BANNER" -> Banner
"COMMERCE" -> @Suppress("DEPRECATION_ERROR") Commerce
"COMMUNITY" -> Community
"CREATOR_MONETIZABLE_PROVISIONAL" -> CreatorMonetizableProvision
"CREATOR_STORE_PAGE" -> CreatorStorePage
"DEVELOPER_SUPPORT_SERVER" -> DeveloperSupportServer
"DISCOVERABLE" -> Discoverable
"FEATURABLE" -> Featurable
Expand All @@ -236,6 +259,8 @@ public sealed class GuildFeature(
"PREVIEW_ENABLED" -> PreviewEnabled
"PRIVATE_THREADS" -> @Suppress("DEPRECATION") PrivateThreads
"ROLE_ICONS" -> RoleIcons
"ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE" -> RoleSubscriptionsAvailableForPurchase
"ROLE_SUBSCRIPTIONS_ENABLED" -> RoleSubscriptionsEnabled
"SEVEN_DAY_THREAD_ARCHIVE" -> @Suppress("DEPRECATION_ERROR") SevenDayThreadArchive
"THREE_DAY_THREAD_ARCHIVE" -> @Suppress("DEPRECATION_ERROR") ThreeDayThreadArchive
"TICKETED_EVENTS_ENABLED" -> TicketedEventsEnabled
Expand All @@ -260,6 +285,8 @@ public sealed class GuildFeature(
Banner,
@Suppress("DEPRECATION_ERROR") Commerce,
Community,
CreatorMonetizableProvision,
CreatorStorePage,
DeveloperSupportServer,
Discoverable,
Featurable,
Expand All @@ -273,6 +300,8 @@ public sealed class GuildFeature(
PreviewEnabled,
@Suppress("DEPRECATION") PrivateThreads,
RoleIcons,
RoleSubscriptionsAvailableForPurchase,
RoleSubscriptionsEnabled,
@Suppress("DEPRECATION_ERROR") SevenDayThreadArchive,
@Suppress("DEPRECATION_ERROR") ThreeDayThreadArchive,
TicketedEventsEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public sealed class MessageType(

public object AutoModerationAction : MessageType(24)

public object RoleSubscriptionPurchase : MessageType(25)

public object InteractionPremiumUpsell : MessageType(26)

public object StageStart : MessageType(27)
Expand Down Expand Up @@ -200,6 +202,7 @@ public sealed class MessageType(
22 -> GuildInviteReminder
23 -> ContextMenuCommand
24 -> AutoModerationAction
25 -> RoleSubscriptionPurchase
26 -> InteractionPremiumUpsell
27 -> StageStart
28 -> StageEnd
Expand Down Expand Up @@ -241,6 +244,7 @@ public sealed class MessageType(
GuildInviteReminder,
ContextMenuCommand,
AutoModerationAction,
RoleSubscriptionPurchase,
InteractionPremiumUpsell,
StageStart,
StageEnd,
Expand Down
28 changes: 27 additions & 1 deletion common/src/main/kotlin/entity/DiscordGuild.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@
kDoc = "Guild can enable welcome screen, Membership Screening, stage channels and discovery, and " +
"receives community updates.",
),
Entry(
"CreatorMonetizableProvision", stringValue = "CREATOR_MONETIZABLE_PROVISIONAL",
kDoc = "Guild has enabled monetization."
),
Entry(
"CreatorStorePage", stringValue = "CREATOR_STORE_PAGE",
kDoc = "Guild has enabled the role subscription promo page."
),
Entry(
"DeveloperSupportServer", stringValue = "DEVELOPER_SUPPORT_SERVER",
kDoc = "Guild has been set as a support server on the App Directory.",
Expand Down Expand Up @@ -116,6 +124,12 @@
kDoc = "Guild can be previewed before joining via Membership Screening or the directory.",
),
Entry("RoleIcons", stringValue = "ROLE_ICONS", kDoc = "Guild is able to set role icons."),
Entry("RoleSubscriptionsAvailableForPurchase", stringValue = "ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE",
kDoc = "Guild has role subscriptions that can be purchased."
),
Entry("RoleSubscriptionsEnabled", stringValue = "ROLE_SUBSCRIPTIONS_ENABLED",
kDoc = "Guild has enabled role subscriptions."
),
Entry(
"TicketedEventsEnabled", stringValue = "TICKETED_EVENTS_ENABLED",
kDoc = "Guild has enabled ticketed events.",
Expand Down Expand Up @@ -374,7 +388,19 @@ public enum class SystemChannelFlag(public val code: Int) {
SuppressJoinNotifications(1.shl(0)),

/** Suppress server boost notifications. **/
SuppressPremiumSubscriptions(1.shl(1))
SuppressPremiumSubscriptions(1.shl(1)),

/** Suppress guild reminder notifications **/
SuppressGuildReminderNotifications(1.shl(2)),

/** Suppress join notification replies **/
SuppressJoinNotificationReplies(1.shl(3)),

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

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

@Serializable
Expand Down
18 changes: 17 additions & 1 deletion common/src/main/kotlin/entity/DiscordMessage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
Entry("GuildInviteReminder", intValue = 22),
Entry("ContextMenuCommand", intValue = 23),
Entry("AutoModerationAction", intValue = 24),
Entry("RoleSubscriptionPurchase", intValue = 25),
Entry("InteractionPremiumUpsell", intValue = 26),
Entry("StageStart", intValue = 27),
Entry("StageEnd", intValue = 28),
Expand Down Expand Up @@ -182,6 +183,7 @@ import kotlin.contracts.contract
* @param flags Message flags.
* @param stickers The stickers sent with the message (bots currently can only receive messages with stickers, not send).
* @param referencedMessage the message associated with [messageReference].
* @param roleSubscriptionData [RoleSubscription] object data of the role subscription purchase or renewal that prompted this message.
* @param applicationId if the message is a response to an [Interaction][DiscordInteraction], this is the id of the interaction's application
* @param components a list of [components][DiscordComponent] which have been added to this message
*/
Expand Down Expand Up @@ -226,6 +228,9 @@ public data class DiscordMessage(
val stickers: Optional<List<DiscordStickerItem>> = Optional.Missing(),
@SerialName("referenced_message")
val referencedMessage: Optional<DiscordMessage?> = Optional.Missing(),
@SerialName("role_subscription_data")
val roleSubscriptionData: Optional<RoleSubscription?> = Optional.Missing(),

/*
* don't trust the docs:
* This is a list even though the docs say it's a component
Expand Down Expand Up @@ -786,11 +791,22 @@ public data class AllowedMentions(
val repliedUser: OptionalBoolean = OptionalBoolean.Missing,
)


@Serializable
public data class DiscordMessageInteraction(
val id: Snowflake,
val type: InteractionType,
val name: String,
val user: DiscordUser,
)

@Serializable
public data class RoleSubscription(
@SerialName("role_subscription_listing_id")
val subscriptionId: Snowflake,
@SerialName("tier_name")
val tierName: String,
@SerialName("total_months_subscribed")
val totalMonthsSubscribed: Int,
@SerialName("is_renewal")
val isRenewal: Boolean
)
6 changes: 6 additions & 0 deletions common/src/main/kotlin/entity/DiscordRole.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public data class DiscordRoleTags(
val integrationId: OptionalSnowflake = OptionalSnowflake.Missing,
@SerialName("premium_subscriber")
val premiumSubscriber: Optional<DiscordNull?> = Optional.Missing(),
@SerialName("subscription_listing_id")
val subscriptionListingId: OptionalSnowflake = OptionalSnowflake.Missing,
@SerialName("available_for_purchase")
val availableForPurchase: Optional<DiscordNull?> = Optional.Missing(),
@SerialName("guild_connections")
val guildConnections: Optional<DiscordNull?> = Optional.Missing(),
)

@Serializable
Expand Down
Loading