@@ -68,22 +68,32 @@ class RoleTags:
68
68
The bot's user ID that manages this role.
69
69
integration_id: Optional[:class:`int`]
70
70
The integration ID that manages the role.
71
+ subscription_listing_id: Optional[:class:`int`]
72
+ The subscription listing ID for the role.
73
+ .. versionadded:: 2.7
71
74
"""
72
75
73
76
__slots__ = (
74
77
"bot_id" ,
75
78
"integration_id" ,
79
+ "subscription_listing_id" ,
76
80
"_premium_subscriber" ,
81
+ "_available_for_purchase" ,
82
+ "_guild_connections"
77
83
)
78
84
79
85
def __init__ (self , data : RoleTagPayload ):
80
86
self .bot_id : int | None = _get_as_snowflake (data , "bot_id" )
81
87
self .integration_id : int | None = _get_as_snowflake (data , "integration_id" )
82
- # NOTE: The API returns "null" for this if it's valid, which corresponds to None.
88
+ self .subscription_listing_id : int | None = _get_as_snowflake (data , "subscription_listing_id" )
89
+ # NOTE: The API returns "null" for this if the following tags True, and doesn't return them at all if False.
90
+ # However, "null" corresponds to None.
83
91
# This is different from other fields where "null" means "not there".
84
92
# So in this case, a value of None is the same as True.
85
93
# Which means we would need a different sentinel.
86
94
self ._premium_subscriber : Any | None = data .get ("premium_subscriber" , MISSING )
95
+ self ._available_for_purchase : Any | None = data .get ("available_for_purchase" , MISSING )
96
+ self ._guild_connections : Any | None = data .get ("guild_connections" , MISSING )
87
97
88
98
def is_bot_managed (self ) -> bool :
89
99
"""Whether the role is associated with a bot."""
@@ -97,10 +107,27 @@ def is_integration(self) -> bool:
97
107
"""Whether the role is managed by an integration."""
98
108
return self .integration_id is not None
99
109
110
+ def is_available_for_purchase (self ) -> bool :
111
+ """Whether the role is available for purchase.
112
+
113
+ .. versionadded:: 2.7
114
+ """
115
+ return self ._available_for_purchase is None
116
+
117
+ def is_guild_connections_role (self ) -> bool :
118
+ """Whether the role is a guild connections role.
119
+
120
+ .. versionadded:: 2.7
121
+ """
122
+ return self ._guild_connections is None
123
+
100
124
def __repr__ (self ) -> str :
101
125
return (
102
126
f"<RoleTags bot_id={ self .bot_id } integration_id={ self .integration_id } "
103
- f"premium_subscriber={ self .is_premium_subscriber ()} >"
127
+ f"subscription_listing_id={ self .subscription_listing_id } "
128
+ f"premium_subscriber={ self .is_premium_subscriber ()} "
129
+ f"available_for_purchase={ self .is_available_for_purchase ()} "
130
+ f"guild_connections={ self .is_guild_connections_role ()} >"
104
131
)
105
132
106
133
@@ -305,6 +332,21 @@ def is_assignable(self) -> bool:
305
332
and (me .top_role > self or me .id == self .guild .owner_id )
306
333
)
307
334
335
+ def is_available_for_purchase (self ) -> bool :
336
+ """Whether the role is available for purchase.
337
+
338
+ .. versionadded:: 2.7
339
+ """
340
+ return self .tags is not None and self .tags .is_available_for_purchase ()
341
+
342
+ def is_guild_connections_role (self ) -> bool :
343
+ """Whether the role is a guild connections role.
344
+
345
+ .. versionadded:: 2.7
346
+ """
347
+ return self .tags is not None and self .tags .is_guild_connections_role ()
348
+
349
+
308
350
@property
309
351
def permissions (self ) -> Permissions :
310
352
"""Returns the role's permissions."""
0 commit comments