@@ -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 each of the following tags if they are True, and omits them 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,36 @@ 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 through 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, and
121
+ ``False`` if it is not available for purchase or if the role
122
+ is not linked to a guild subscription.
123
+
124
+ .. versionadded:: 2.7
125
+ """
126
+ return self ._available_for_purchase is None
127
+
128
+ def is_guild_connections_role (self ) -> bool :
129
+ """Whether the role is a guild connections role.
130
+
131
+ .. versionadded:: 2.7
132
+ """
133
+ return self ._guild_connections is None
134
+
100
135
def __repr__ (self ) -> str :
101
136
return (
102
137
f"<RoleTags bot_id={ self .bot_id } integration_id={ self .integration_id } "
103
- f"premium_subscriber={ self .is_premium_subscriber ()} >"
138
+ f"subscription_listing_id={ self .subscription_listing_id } "
139
+ f"premium_subscriber={ self .is_premium_subscriber ()} "
140
+ f"available_for_purchase={ self .is_available_for_purchase ()} "
141
+ f"guild_connections={ self .is_guild_connections_role ()} >"
104
142
)
105
143
106
144
@@ -167,8 +205,10 @@ class Role(Hashable):
167
205
operators on the role objects themselves.
168
206
169
207
managed: :class:`bool`
170
- Indicates if the role is managed by the guild through some form of
171
- integrations such as Twitch.
208
+ Indicates if the role is managed by the guild.
209
+ This is true if any of :meth:`Role.is_integration`, :meth:`Role.is_premium_subscriber`,
210
+ :meth:`Role.is_bot_managed` or :meth:`Role.is_guild_connections_role`
211
+ is ``True``.
172
212
mentionable: :class:`bool`
173
213
Indicates if the role can be mentioned by users.
174
214
tags: Optional[:class:`RoleTags`]
@@ -287,7 +327,8 @@ def is_premium_subscriber(self) -> bool:
287
327
return self .tags is not None and self .tags .is_premium_subscriber ()
288
328
289
329
def is_integration (self ) -> bool :
290
- """Whether the role is managed by an integration.
330
+ """Whether the guild manages the role through some form of
331
+ integrations such as Twitch or through guild subscriptions.
291
332
292
333
.. versionadded:: 1.6
293
334
"""
@@ -305,6 +346,24 @@ def is_assignable(self) -> bool:
305
346
and (me .top_role > self or me .id == self .guild .owner_id )
306
347
)
307
348
349
+ def is_available_for_purchase (self ) -> bool :
350
+ """Whether the role is available for purchase.
351
+
352
+ Returns ``True`` if the role is available for purchase, and
353
+ ``False`` if it is not available for purchase or if the
354
+ role is not linked to a guild subscription.
355
+
356
+ .. versionadded:: 2.7
357
+ """
358
+ return self .tags is not None and self .tags .is_available_for_purchase ()
359
+
360
+ def is_guild_connections_role (self ) -> bool :
361
+ """Whether the role is a guild connections role.
362
+
363
+ .. versionadded:: 2.7
364
+ """
365
+ return self .tags is not None and self .tags .is_guild_connections_role ()
366
+
308
367
@property
309
368
def permissions (self ) -> Permissions :
310
369
"""Returns the role's permissions."""
0 commit comments