Skip to content

Commit d72e865

Browse files
docs: Improve RoleType and related docs somewhat (#3169)
Co-authored-by: plun1331 <plun1331@gmail.com>
1 parent 5cda9e5 commit d72e865

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

discord/enums.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ class SelectDefaultValueType(Enum):
11391139
class RoleType(IntEnum):
11401140
"""Represents the type of role.
11411141
1142-
This is NOT provided by Discord but is rather computed based on :attr:`Role.tags`.
1142+
This is NOT provided by Discord but is rather computed from :attr:`Role.tags`.
11431143
11441144
.. versionadded:: 2.8
11451145
@@ -1156,7 +1156,8 @@ class RoleType(IntEnum):
11561156
11571157
.. note::
11581158
This is not possible to determine at times because role tags seem to be missing altogether, notably when
1159-
a role is fetched. In such cases :attr:`Role.type` and :attr:`Role.tags` will both be :data:`None`.
1159+
a guild product role is fetched.
1160+
In such cases :attr:`Role.type` will be :attr:`RoleType.NORMAL` and :attr:`Role.tags` will be :data:`None`.
11601161
PREMIUM_SUBSCRIPTION_BASE: :class:`int`
11611162
The role is a base subscription role.
11621163

discord/role.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,41 +213,49 @@ def type(self) -> RoleType:
213213
return RoleType.UNKNOWN
214214

215215
@deprecated(
216-
"RoleTags.is_bot_managed is deprecated since version 2.8, consider using RoleTags.type instead."
216+
"RoleTags.is_bot_managed is deprecated since version 2.8,"
217+
+ " consider using RoleTags.type == RoleType.APPLICATION instead."
217218
)
218219
def is_bot_managed(self) -> bool:
219220
"""Whether the role is associated with a bot.
220221
221222
.. deprecated:: 2.8
222-
Use :attr:`RoleTags.type` instead.
223+
Use ``RoleTags.type == RoleType.APPLICATION`` instead.
223224
"""
224225
return self.bot_id is not None
225226

226227
@deprecated(
227-
"RoleTags.is_premium_subscriber is deprecated since version 2.8, consider using RoleTags.type instead."
228+
"RoleTags.is_premium_subscriber is deprecated since version 2.8,"
229+
+ " consider using RoleTags.type == RoleType.BOOSTER instead."
228230
)
229231
def is_premium_subscriber(self) -> bool:
230232
"""Whether the role is the premium subscriber, AKA "boost", role for the guild.
231233
232234
.. deprecated:: 2.8
233-
Use :attr:`RoleTags.type` instead.
235+
Use ``RoleTags.type == RoleType.BOOSTER`` instead.
234236
"""
235237
return self._premium_subscriber is True
236238

237239
@deprecated(
238-
"RoleTags.is_integration is deprecated since version 2.8, consider using RoleTags.type instead."
240+
"RoleTags.is_integration is deprecated since version 2.8,"
241+
+ " consider using RoleTags.type in"
242+
+ " (RoleType.INTEGRATION, RoleType.PREMIUM_SUBSCRIPTION_TIER,"
243+
+ " RoleType.DRAFT_PREMIUM_SUBSCRIPTION_TIER) instead."
239244
)
240245
def is_integration(self) -> bool:
241246
"""Whether the guild manages the role through some form of
242247
integrations such as Twitch or through guild subscriptions.
243248
244249
.. deprecated:: 2.8
245-
Use :attr:`RoleTags.type` instead.
250+
Use ``RoleTags.type in (RoleType.INTEGRATION,
251+
RoleType.PREMIUM_SUBSCRIPTION_TIER,
252+
RoleType.DRAFT_PREMIUM_SUBSCRIPTION_TIER)`` instead.
246253
"""
247254
return self.integration_id is not None
248255

249256
@deprecated(
250-
"RoleTags.is_available_for_purchase is deprecated since version 2.8, consider using RoleTags.type instead."
257+
"RoleTags.is_available_for_purchase is deprecated since version 2.8,"
258+
+ " consider using RoleTags.type == RoleType.PREMIUM_SUBSCRIPTION_TIER instead."
251259
)
252260
def is_available_for_purchase(self) -> bool:
253261
"""Whether the role is available for purchase.
@@ -257,20 +265,21 @@ def is_available_for_purchase(self) -> bool:
257265
is not linked to a guild subscription.
258266
259267
.. deprecated:: 2.8
260-
Use :attr:`RoleTags.type` instead.
268+
Use ``RoleTags.type == RoleType.PREMIUM_SUBSCRIPTION_TIER`` instead.
261269
262270
.. versionadded:: 2.7
263271
"""
264272
return self._available_for_purchase is True
265273

266274
@deprecated(
267-
"RoleTags.is_guild_connections_role is deprecated since version 2.8, consider using RoleTags.type instead."
275+
"RoleTags.is_guild_connections_role is deprecated since version 2.8,"
276+
+ " consider using RoleTags.type == RoleType.CONNECTION instead."
268277
)
269278
def is_guild_connections_role(self) -> bool:
270279
"""Whether the role is a guild connections role.
271280
272281
.. deprecated:: 2.8
273-
Use :attr:`RoleTags.type` instead.
282+
Use ``RoleTags.type == RoleType.CONNECTION`` instead.
274283
275284
.. versionadded:: 2.7
276285
"""

0 commit comments

Comments
 (0)