@@ -68,22 +68,37 @@ class RoleTags:
6868 The bot's user ID that manages this role.
6969 integration_id: Optional[:class:`int`]
7070 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
7175 """
7276
7377 __slots__ = (
7478 "bot_id" ,
7579 "integration_id" ,
80+ "subscription_listing_id" ,
7681 "_premium_subscriber" ,
82+ "_available_for_purchase" ,
83+ "_guild_connections" ,
7784 )
7885
7986 def __init__ (self , data : RoleTagPayload ):
8087 self .bot_id : int | None = _get_as_snowflake (data , "bot_id" )
8188 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.
8394 # This is different from other fields where "null" means "not there".
8495 # So in this case, a value of None is the same as True.
8596 # Which means we would need a different sentinel.
8697 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 )
87102
88103 def is_bot_managed (self ) -> bool :
89104 """Whether the role is associated with a bot."""
@@ -94,13 +109,35 @@ def is_premium_subscriber(self) -> bool:
94109 return self ._premium_subscriber is None
95110
96111 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+ """
98115 return self .integration_id is not None
99116
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+
100134 def __repr__ (self ) -> str :
101135 return (
102136 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 ()} >"
104141 )
105142
106143
@@ -167,7 +204,10 @@ class Role(Hashable):
167204 operators on the role objects themselves.
168205
169206 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``.
171211 mentionable: :class:`bool`
172212 Indicates if the role can be mentioned by users.
173213 tags: Optional[:class:`RoleTags`]
@@ -286,8 +326,8 @@ def is_premium_subscriber(self) -> bool:
286326 return self .tags is not None and self .tags .is_premium_subscriber ()
287327
288328 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 .
291331
292332 .. versionadded:: 1.6
293333 """
@@ -305,6 +345,23 @@ def is_assignable(self) -> bool:
305345 and (me .top_role > self or me .id == self .guild .owner_id )
306346 )
307347
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+
308365 @property
309366 def permissions (self ) -> Permissions :
310367 """Returns the role's permissions."""
0 commit comments