From b4eb619852d6219c33bd01479a5607a5bc55ea7f Mon Sep 17 00:00:00 2001 From: DeltaX <33706469+DeltaXWizard@users.noreply.github.com> Date: Tue, 6 Dec 2022 15:38:36 -0500 Subject: [PATCH 1/4] docs, feat: Implement barebones Premium Membership support. (Recommitted via very old branch, origin commit hash 936a0f8c85134a93fe190c496eceb267ca6b4633) --- interactions/api/models/gw.py | 4 ++++ interactions/api/models/role.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/interactions/api/models/gw.py b/interactions/api/models/gw.py index 52eb94f89..fcc742417 100644 --- a/interactions/api/models/gw.py +++ b/interactions/api/models/gw.py @@ -223,10 +223,14 @@ class GuildJoinRequest(DictSerializerMixin): :ivar Snowflake user_id: The user ID of the event. :ivar Snowflake guild_id: The guild ID of the event. + :ivar Optional[Any] request: The actual request representing the event. This pertains primarily to _CREATE, but maybe _UPDATE as well. + :ivar Optional[str] status: The status of the event, which pertains to _CREATE. """ user_id: Snowflake = field(converter=Snowflake) guild_id: Snowflake = field(converter=Snowflake) + request: Optional[Any] = field(default=None) + status: Optional[str] = field(default=None) @define() diff --git a/interactions/api/models/role.py b/interactions/api/models/role.py index cb1b7bf78..c61141d63 100644 --- a/interactions/api/models/role.py +++ b/interactions/api/models/role.py @@ -22,13 +22,16 @@ class RoleTags(DictSerializerMixin): :ivar Optional[Snowflake] bot_id?: The id of the bot this role belongs to :ivar Optional[Snowflake] integration_id?: The id of the integration this role belongs to :ivar Optional[Any] premium_subscriber?: Whether if this is the guild's premium subscriber role + :ivar Optional[Snowflake] subscription_listing_id?: The id of the linked premium membership role, if any. + :ivar Optional[bool] purchasable_or_has_subscribers?: Whether the role can be purchasable via premium membership or that the role contains subscribers, if any. """ bot_id: Optional[Snowflake] = field(converter=Snowflake, default=None) integration_id: Optional[Snowflake] = field(converter=Snowflake, default=None) premium_subscriber: Optional[Any] = field(default=None) - # TODO: Figure out what actual type it returns, all it says is null. + subscription_listing_id: Optional[Snowflake] = field(converter=Snowflake, default=None) + purchasable_or_has_subscribers: Optional[bool] = field(default=None) @define() From 32742587c4f9bfe52941c1b79b27807c175f818a Mon Sep 17 00:00:00 2001 From: DeltaX <33706469+DeltaXWizard@users.noreply.github.com> Date: Tue, 6 Dec 2022 15:46:13 -0500 Subject: [PATCH 2/4] docs, feat: Implement unofficial new MessageType and AuditLogEvent type. --- interactions/api/models/audit_log.py | 8 ++++++++ interactions/api/models/message.py | 8 +++++++- interactions/api/models/role.py | 6 +++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/interactions/api/models/audit_log.py b/interactions/api/models/audit_log.py index a94827d05..55fd76509 100644 --- a/interactions/api/models/audit_log.py +++ b/interactions/api/models/audit_log.py @@ -27,6 +27,9 @@ class AuditLogEvents(IntEnum): """ A class object representing the different types of AuditLogEvents. + .. note:: + There is no official name for AuditLogEvents type 151, however it does represent the server owner sets up the guild for monetization/server subscriptions. + :ivar int GUILD_UPDATE: 1 - Server settings were updated :ivar int CHANNEL_CREATE: 10 - Channel was created :ivar int CHANNEL_UPDATE: 11 - Channel settings were updated @@ -81,6 +84,7 @@ class AuditLogEvents(IntEnum): :ivar int AUTO_MODERATION_BLOCK_MESSAGE: 143 - Message was blocked by AutoMod (according to a rule) :ivar int AUTO_MODERATION_FLAG_TO_CHANNEL: 144 - Message was flagged by AutoMod (according to a rule) :ivar int AUTO_MODERATION_USER_COMMUNICATION_DISABLED: 145 - Member was timed out by AutoMod (according to a rule) + :ivar int GUILD_MONETIZATION_SETUP: 151 - Monetization was set up in the server. """ # guild related @@ -167,6 +171,10 @@ class AuditLogEvents(IntEnum): AUTO_MODERATION_FLAG_TO_CHANNEL = 144 AUTO_MODERATION_USER_COMMUNICATION_DISABLED = 145 + # monetization related + + GUILD_MONETIZATION_SETUP = 151 + @define() class AuditLogChange(DictSerializerMixin): diff --git a/interactions/api/models/message.py b/interactions/api/models/message.py index 318383faa..f9febcb10 100644 --- a/interactions/api/models/message.py +++ b/interactions/api/models/message.py @@ -48,7 +48,12 @@ class MessageType(IntEnum): - """An enumerable object representing the types of messages.""" + """ + An enumerable object representing the types of messages. + + .. note:: + There is no official name for MessageType 25, however it does represent when someone subscribes to a server for the first time. + """ DEFAULT = 0 RECIPIENT_ADD = 1 @@ -74,6 +79,7 @@ class MessageType(IntEnum): GUILD_INVITE_REMINDER = 22 CONTEXT_MENU_COMMAND = 23 AUTO_MODERATION_ACTION = 24 + USER_NEWLY_SUBSCRIBED = 25 @define() diff --git a/interactions/api/models/role.py b/interactions/api/models/role.py index c61141d63..7d39b540d 100644 --- a/interactions/api/models/role.py +++ b/interactions/api/models/role.py @@ -21,9 +21,9 @@ class RoleTags(DictSerializerMixin): :ivar Optional[Snowflake] bot_id?: The id of the bot this role belongs to :ivar Optional[Snowflake] integration_id?: The id of the integration this role belongs to - :ivar Optional[Any] premium_subscriber?: Whether if this is the guild's premium subscriber role - :ivar Optional[Snowflake] subscription_listing_id?: The id of the linked premium membership role, if any. - :ivar Optional[bool] purchasable_or_has_subscribers?: Whether the role can be purchasable via premium membership or that the role contains subscribers, if any. + :ivar Optional[Any] premium_subscriber?: Whether if this is the guild's server subscription role + :ivar Optional[Snowflake] subscription_listing_id?: The id of the linked server subscription role, if any. + :ivar Optional[bool] purchasable_or_has_subscribers?: Whether the role can be purchasable via server subscription or that the role contains subscribers, if any. """ bot_id: Optional[Snowflake] = field(converter=Snowflake, default=None) From ee8783228d6f04a0be1b6a8892cdd13aa3c676a5 Mon Sep 17 00:00:00 2001 From: DeltaX <33706469+DeltaXWizard@users.noreply.github.com> Date: Thu, 8 Dec 2022 09:55:13 -0500 Subject: [PATCH 3/4] docs: Remove `?` on RoleTags object attribute docs. --- interactions/api/models/role.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/interactions/api/models/role.py b/interactions/api/models/role.py index 7d39b540d..2e4e6fd5b 100644 --- a/interactions/api/models/role.py +++ b/interactions/api/models/role.py @@ -19,11 +19,11 @@ class RoleTags(DictSerializerMixin): """ A class object representing the tags of a role. - :ivar Optional[Snowflake] bot_id?: The id of the bot this role belongs to - :ivar Optional[Snowflake] integration_id?: The id of the integration this role belongs to - :ivar Optional[Any] premium_subscriber?: Whether if this is the guild's server subscription role - :ivar Optional[Snowflake] subscription_listing_id?: The id of the linked server subscription role, if any. - :ivar Optional[bool] purchasable_or_has_subscribers?: Whether the role can be purchasable via server subscription or that the role contains subscribers, if any. + :ivar Optional[Snowflake] bot_id: The id of the bot this role belongs to + :ivar Optional[Snowflake] integration_id: The id of the integration this role belongs to + :ivar Optional[Any] premium_subscriber: Whether if this is the guild's server subscription role + :ivar Optional[Snowflake] subscription_listing_id: The id of the linked server subscription role, if any. + :ivar Optional[bool] purchasable_or_has_subscribers: Whether the role can be purchasable via server subscription or that the role contains subscribers, if any. """ bot_id: Optional[Snowflake] = field(converter=Snowflake, default=None) From 18b1b7867e7b88a6332ad4907710686744f716d7 Mon Sep 17 00:00:00 2001 From: DeltaX <33706469+DeltaXWizard@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:19:54 -0500 Subject: [PATCH 4/4] docs, feat: Include server-subscriptions related error codes, enums, and proper nomenclature. (according to discord-api-docs, ebebc249cbe817c0927b17189b533f4d60715961) --- interactions/api/error.py | 3 +++ interactions/api/models/guild.py | 2 ++ interactions/api/models/message.py | 2 +- interactions/api/models/role.py | 15 ++++++++++----- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/interactions/api/error.py b/interactions/api/error.py index 2b26d0d7c..77a7e8869 100644 --- a/interactions/api/error.py +++ b/interactions/api/error.py @@ -198,6 +198,7 @@ def lookup(code: int) -> str: 30047: "Maximum number of pinned threads in a forum channel has been reached", 30048: "Maximum number of tags in a forum channel has been reached", 30052: "Bitrate is too high for channel of this type", + 30056: "Maximum number of premium emojis reached (25)", 31001: "Undocumented error/rate-limit related.", 40001: "Unauthorized. Provide a valid token and try again", 40002: "You need to verify your account in order to perform this action", @@ -267,6 +268,8 @@ def lookup(code: int) -> str: 50109: "The request body contains invalid JSON.", 50132: "Ownership cannot be transferred to a bot user", 50138: "Failed to resize asset below the maximum size: 262144", + 50144: "Cannot mix subscription and non subscription roles for an emoji", + 50145: "Cannot convert between premium emoji and normal emoji", 50146: "Uploaded file not found.", 50600: "You do not have permission to send this sticker.", 60003: "Two factor is required for this operation", diff --git a/interactions/api/models/guild.py b/interactions/api/models/guild.py index 85017e7f5..13bb7085e 100644 --- a/interactions/api/models/guild.py +++ b/interactions/api/models/guild.py @@ -140,6 +140,8 @@ class GuildFeatures(Enum): PREVIEW_ENABLED = "PREVIEW_ENABLED" PRIVATE_THREADS = "PRIVATE_THREADS" ROLE_ICONS = "ROLE_ICONS" + ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE = "ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE" + ROLE_SUBSCRIPTIONS_ENABLED = "ROLE_SUBSCRIPTIONS_ENABLED" TICKETED_EVENTS_ENABLED = "TICKETED_EVENTS_ENABLED" VANITY_URL = "VANITY_URL" VERIFIED = "VERIFIED" diff --git a/interactions/api/models/message.py b/interactions/api/models/message.py index ea222bfa4..2dbf308a9 100644 --- a/interactions/api/models/message.py +++ b/interactions/api/models/message.py @@ -80,7 +80,7 @@ class MessageType(IntEnum): GUILD_INVITE_REMINDER = 22 CONTEXT_MENU_COMMAND = 23 AUTO_MODERATION_ACTION = 24 - USER_NEWLY_SUBSCRIBED = 25 + ROLE_SUBSCRIPTION_PURCHASE = 25 @staticmethod def not_deletable() -> List[int]: diff --git a/interactions/api/models/role.py b/interactions/api/models/role.py index 5d13f3c6b..46376a126 100644 --- a/interactions/api/models/role.py +++ b/interactions/api/models/role.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, List, Optional, Union +from typing import TYPE_CHECKING, List, Optional, Union from ...utils.attrs_utils import ClientSerializerMixin, DictSerializerMixin, define, field from ...utils.missing import MISSING @@ -19,16 +19,21 @@ class RoleTags(DictSerializerMixin): """ A class object representing the tags of a role. + .. note :: + With the premium_subscriber and available_for_purchase attributes currently, + if the attribute is present and "null" it's true, and if the attribute is not present it's false. + + :ivar Optional[Snowflake] bot_id: The id of the bot this role belongs to :ivar Optional[Snowflake] integration_id: The id of the integration this role belongs to - :ivar Optional[Any] premium_subscriber: Whether if this is the guild's server subscription role - :ivar Optional[Snowflake] subscription_listing_id: The id of the linked server subscription role, if any. - :ivar Optional[bool] purchasable_or_has_subscribers: Whether the role can be purchasable via server subscription or that the role contains subscribers, if any. + :ivar Optional[bool] premium_subscriber: Whether if this is the guild's booster role. + :ivar Optional[Snowflake] subscription_listing_id: The id of this role's subscription sku and listing, if any. + :ivar Optional[bool] available_for_purchase: Whether this role is available for purchase. """ bot_id: Optional[Snowflake] = field(converter=Snowflake, default=None) integration_id: Optional[Snowflake] = field(converter=Snowflake, default=None) - premium_subscriber: Optional[Any] = field(default=None) + premium_subscriber: Optional[bool] = field(default=None) subscription_listing_id: Optional[Snowflake] = field(converter=Snowflake, default=None) purchasable_or_has_subscribers: Optional[bool] = field(default=None)