@@ -68,22 +68,37 @@ 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 SKU and listing ID of the role.
73
+
74
+ .. versionadded:: 2.7
71
75
"""
72
76
73
77
__slots__ = (
74
78
"bot_id" ,
75
79
"integration_id" ,
80
+ "subscription_listing_id" ,
76
81
"_premium_subscriber" ,
82
+ "_available_for_purchase" ,
83
+ "_guild_connections" ,
77
84
)
78
85
79
86
def __init__ (self , data : RoleTagPayload ):
80
87
self .bot_id : int | None = _get_as_snowflake (data , "bot_id" )
81
88
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.
89
+ self .subscription_listing_id : int | None = _get_as_snowflake (
90
+ data , "subscription_listing_id"
91
+ )
92
+ # NOTE: The API returns "null" for this if the following tags True, and doesn't return them at all if False.
93
+ # However, "null" corresponds to None.
83
94
# This is different from other fields where "null" means "not there".
84
95
# So in this case, a value of None is the same as True.
85
96
# Which means we would need a different sentinel.
86
97
self ._premium_subscriber : Any | None = data .get ("premium_subscriber" , MISSING )
98
+ self ._available_for_purchase : Any | None = data .get (
99
+ "available_for_purchase" , MISSING
100
+ )
101
+ self ._guild_connections : Any | None = data .get ("guild_connections" , MISSING )
87
102
88
103
def is_bot_managed (self ) -> bool :
89
104
"""Whether the role is associated with a bot."""
@@ -94,13 +109,35 @@ def is_premium_subscriber(self) -> bool:
94
109
return self ._premium_subscriber is None
95
110
96
111
def is_integration (self ) -> bool :
97
- """Whether the role is managed by an integration."""
112
+ """Whether the guild manages the role through some form of
113
+ integrations such as Twitch or trough guild subscriptions.
114
+ """
98
115
return self .integration_id is not None
99
116
117
+ def is_available_for_purchase (self ) -> bool :
118
+ """Whether the role is available for purchase.
119
+
120
+ Returns ``True`` if the role is available for purchase,
121
+ ``False`` if it is not or if the role is not linked to a guild subscription.
122
+
123
+ .. versionadded:: 2.7
124
+ """
125
+ return self ._available_for_purchase is None
126
+
127
+ def is_guild_connections_role (self ) -> bool :
128
+ """Whether the role is a guild connections role.
129
+
130
+ .. Versionadded:: 2.7
131
+ """
132
+ return self ._guild_connections is None
133
+
100
134
def __repr__ (self ) -> str :
101
135
return (
102
136
f"<RoleTags bot_id={ self .bot_id } integration_id={ self .integration_id } "
103
- f"premium_subscriber={ self .is_premium_subscriber ()} >"
137
+ f"subscription_listing_id={ self .subscription_listing_id } "
138
+ f"premium_subscriber={ self .is_premium_subscriber ()} "
139
+ f"available_for_purchase={ self .is_available_for_purchase ()} "
140
+ f"guild_connections={ self .is_guild_connections_role ()} >"
104
141
)
105
142
106
143
@@ -167,7 +204,10 @@ class Role(Hashable):
167
204
operators on the role objects themselves.
168
205
169
206
managed: :class:`bool`
170
- Indicates if the role is managed by the guild. This is true if :meth:`Role.is_integration`, :meth:`Role.is_premium_subscriber`, or :meth:`Role.is_bot_managed` is ``True``.
207
+ Indicates if the role is managed by the guild.
208
+ This is true if any of :meth:`Role.is_integration`, :meth:`Role.is_premium_subscriber`,
209
+ :meth:`Role.is_bot_managed` or :meth:`Role.is_guild_connections_role`
210
+ are ``True``.
171
211
mentionable: :class:`bool`
172
212
Indicates if the role can be mentioned by users.
173
213
tags: Optional[:class:`RoleTags`]
@@ -286,8 +326,8 @@ def is_premium_subscriber(self) -> bool:
286
326
return self .tags is not None and self .tags .is_premium_subscriber ()
287
327
288
328
def is_integration (self ) -> bool :
289
- """Whether the role is managed by the guild through some form of
290
- integrations such as Twitch.
329
+ """Whether the guild manages the role through some form of
330
+ integrations such as Twitch or trough guild subscriptions .
291
331
292
332
.. versionadded:: 1.6
293
333
"""
@@ -305,6 +345,23 @@ def is_assignable(self) -> bool:
305
345
and (me .top_role > self or me .id == self .guild .owner_id )
306
346
)
307
347
348
+ def is_available_for_purchase (self ) -> bool :
349
+ """Whether the role is available for purchase.
350
+
351
+ Returns ``True`` if the role is available for purchase,
352
+ ``False`` if it is not or if the role is not linked to a guild subscription.
353
+
354
+ .. versionadded:: 2.7
355
+ """
356
+ return self .tags is not None and self .tags .is_available_for_purchase ()
357
+
358
+ def is_guild_connections_role (self ) -> bool :
359
+ """Whether the role is a guild connections role.
360
+
361
+ .. versionadded:: 2.7
362
+ """
363
+ return self .tags is not None and self .tags .is_guild_connections_role ()
364
+
308
365
@property
309
366
def permissions (self ) -> Permissions :
310
367
"""Returns the role's permissions."""
0 commit comments