@@ -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 each of the following tags if they are True, and omits them 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,36 @@ 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 through 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, 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+
100135 def __repr__ (self ) -> str :
101136 return (
102137 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 ()} >"
104142 )
105143
106144
@@ -167,8 +205,10 @@ class Role(Hashable):
167205 operators on the role objects themselves.
168206
169207 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``.
172212 mentionable: :class:`bool`
173213 Indicates if the role can be mentioned by users.
174214 tags: Optional[:class:`RoleTags`]
@@ -287,7 +327,8 @@ def is_premium_subscriber(self) -> bool:
287327 return self .tags is not None and self .tags .is_premium_subscriber ()
288328
289329 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.
291332
292333 .. versionadded:: 1.6
293334 """
@@ -305,6 +346,24 @@ def is_assignable(self) -> bool:
305346 and (me .top_role > self or me .id == self .guild .owner_id )
306347 )
307348
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+
308367 @property
309368 def permissions (self ) -> Permissions :
310369 """Returns the role's permissions."""
0 commit comments