@@ -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
@@ -167,7 +194,9 @@ class Role(Hashable):
167
194
operators on the role objects themselves.
168
195
169
196
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``.
197
+ Indicates if the role is managed by the guild.
198
+ This is true if any of :meth:`Role.is_integration`, :meth:`Role.is_premium_subscriber`,
199
+ or :meth:`Role.is_bot_managed` are ``True``.
171
200
mentionable: :class:`bool`
172
201
Indicates if the role can be mentioned by users.
173
202
tags: Optional[:class:`RoleTags`]
@@ -305,6 +334,20 @@ def is_assignable(self) -> bool:
305
334
and (me .top_role > self or me .id == self .guild .owner_id )
306
335
)
307
336
337
+ def is_available_for_purchase (self ) -> bool :
338
+ """Whether the role is available for purchase.
339
+
340
+ .. versionadded:: 2.7
341
+ """
342
+ return self .tags is not None and self .tags .is_available_for_purchase ()
343
+
344
+ def is_guild_connections_role (self ) -> bool :
345
+ """Whether the role is a guild connections role.
346
+
347
+ .. versionadded:: 2.7
348
+ """
349
+ return self .tags is not None and self .tags .is_guild_connections_role ()
350
+
308
351
@property
309
352
def permissions (self ) -> Permissions :
310
353
"""Returns the role's permissions."""
0 commit comments