Skip to content

Commit a9e97ca

Browse files
authored
feat: Implement barebones Premium Membership support. (#767)
* docs, feat: Implement barebones Premium Membership support. (Recommitted via very old branch, origin commit hash 936a0f8) * docs, feat: Implement unofficial new MessageType and AuditLogEvent type.
1 parent a898c40 commit a9e97ca

File tree

6 files changed

+36
-5
lines changed

6 files changed

+36
-5
lines changed

interactions/api/error.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ def lookup(code: int) -> str:
198198
30047: "Maximum number of pinned threads in a forum channel has been reached",
199199
30048: "Maximum number of tags in a forum channel has been reached",
200200
30052: "Bitrate is too high for channel of this type",
201+
30056: "Maximum number of premium emojis reached (25)",
201202
31001: "Undocumented error/rate-limit related.",
202203
40001: "Unauthorized. Provide a valid token and try again",
203204
40002: "You need to verify your account in order to perform this action",
@@ -267,6 +268,8 @@ def lookup(code: int) -> str:
267268
50109: "The request body contains invalid JSON.",
268269
50132: "Ownership cannot be transferred to a bot user",
269270
50138: "Failed to resize asset below the maximum size: 262144",
271+
50144: "Cannot mix subscription and non subscription roles for an emoji",
272+
50145: "Cannot convert between premium emoji and normal emoji",
270273
50146: "Uploaded file not found.",
271274
50600: "You do not have permission to send this sticker.",
272275
60003: "Two factor is required for this operation",

interactions/api/models/audit_log.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ class AuditLogEvents(IntEnum):
2929
"""
3030
A class object representing the different types of AuditLogEvents.
3131
32+
.. note::
33+
There is no official name for AuditLogEvents type 151, however it does represent the server owner sets up the guild for monetization/server subscriptions.
34+
3235
:ivar int GUILD_UPDATE: 1 - Server settings were updated
3336
:ivar int CHANNEL_CREATE: 10 - Channel was created
3437
:ivar int CHANNEL_UPDATE: 11 - Channel settings were updated
@@ -83,6 +86,7 @@ class AuditLogEvents(IntEnum):
8386
:ivar int AUTO_MODERATION_BLOCK_MESSAGE: 143 - Message was blocked by AutoMod (according to a rule)
8487
:ivar int AUTO_MODERATION_FLAG_TO_CHANNEL: 144 - Message was flagged by AutoMod (according to a rule)
8588
:ivar int AUTO_MODERATION_USER_COMMUNICATION_DISABLED: 145 - Member was timed out by AutoMod (according to a rule)
89+
:ivar int GUILD_MONETIZATION_SETUP: 151 - Monetization was set up in the server.
8690
"""
8791

8892
# guild related
@@ -169,6 +173,10 @@ class AuditLogEvents(IntEnum):
169173
AUTO_MODERATION_FLAG_TO_CHANNEL = 144
170174
AUTO_MODERATION_USER_COMMUNICATION_DISABLED = 145
171175

176+
# monetization related
177+
178+
GUILD_MONETIZATION_SETUP = 151
179+
172180

173181
@define()
174182
class AuditLogChange(DictSerializerMixin):

interactions/api/models/guild.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ class GuildFeatures(Enum):
140140
PREVIEW_ENABLED = "PREVIEW_ENABLED"
141141
PRIVATE_THREADS = "PRIVATE_THREADS"
142142
ROLE_ICONS = "ROLE_ICONS"
143+
ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE = "ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE"
144+
ROLE_SUBSCRIPTIONS_ENABLED = "ROLE_SUBSCRIPTIONS_ENABLED"
143145
TICKETED_EVENTS_ENABLED = "TICKETED_EVENTS_ENABLED"
144146
VANITY_URL = "VANITY_URL"
145147
VERIFIED = "VERIFIED"

interactions/api/models/gw.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,14 @@ class GuildJoinRequest(DictSerializerMixin):
258258
259259
:ivar Snowflake user_id: The user ID of the event.
260260
:ivar Snowflake guild_id: The guild ID of the event.
261+
:ivar Optional[Any] request: The actual request representing the event. This pertains primarily to _CREATE, but maybe _UPDATE as well.
262+
:ivar Optional[str] status: The status of the event, which pertains to _CREATE.
261263
"""
262264

263265
user_id: Snowflake = field(converter=Snowflake)
264266
guild_id: Snowflake = field(converter=Snowflake)
267+
request: Optional[Any] = field(default=None)
268+
status: Optional[str] = field(default=None)
265269

266270

267271
@define()

interactions/api/models/message.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@
4949

5050

5151
class MessageType(IntEnum):
52-
"""An enumerable object representing the types of messages."""
52+
"""
53+
An enumerable object representing the types of messages.
54+
55+
.. note::
56+
There is no official name for MessageType 25, however it does represent when someone subscribes to a server for the first time.
57+
"""
5358

5459
DEFAULT = 0
5560
RECIPIENT_ADD = 1
@@ -75,6 +80,7 @@ class MessageType(IntEnum):
7580
GUILD_INVITE_REMINDER = 22
7681
CONTEXT_MENU_COMMAND = 23
7782
AUTO_MODERATION_ACTION = 24
83+
ROLE_SUBSCRIPTION_PURCHASE = 25
7884

7985
@staticmethod
8086
def not_deletable() -> List[int]:

interactions/api/models/role.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TYPE_CHECKING, Any, List, Optional, Union
1+
from typing import TYPE_CHECKING, List, Optional, Union
22

33
from ...utils.attrs_utils import ClientSerializerMixin, DictSerializerMixin, define, field
44
from ...utils.missing import MISSING
@@ -19,16 +19,24 @@ class RoleTags(DictSerializerMixin):
1919
"""
2020
A class object representing the tags of a role.
2121
22+
.. note ::
23+
With the premium_subscriber and available_for_purchase attributes currently,
24+
if the attribute is present and "null" it's true, and if the attribute is not present it's false.
25+
26+
2227
:ivar Optional[Snowflake] bot_id: The id of the bot this role belongs to
2328
:ivar Optional[Snowflake] integration_id: The id of the integration this role belongs to
24-
:ivar Optional[Any] premium_subscriber: Whether if this is the guild's premium subscriber role
29+
:ivar Optional[bool] premium_subscriber: Whether if this is the guild's booster role.
30+
:ivar Optional[Snowflake] subscription_listing_id: The id of this role's subscription sku and listing, if any.
31+
:ivar Optional[bool] available_for_purchase: Whether this role is available for purchase.
2532
"""
2633

2734
bot_id: Optional[Snowflake] = field(converter=Snowflake, default=None)
2835
integration_id: Optional[Snowflake] = field(converter=Snowflake, default=None)
29-
premium_subscriber: Optional[Any] = field(default=None)
36+
premium_subscriber: Optional[bool] = field(default=None)
3037

31-
# TODO: Figure out what actual type it returns, all it says is null.
38+
subscription_listing_id: Optional[Snowflake] = field(converter=Snowflake, default=None)
39+
purchasable_or_has_subscribers: Optional[bool] = field(default=None)
3240

3341

3442
@define()

0 commit comments

Comments
 (0)