@@ -144,9 +144,10 @@ class RoleType(IntEnum):
144
144
GUILD_PRODUCT = 3
145
145
PREMIUM_SUBSCRIPTION_BASE = 4 # Not possible to determine currently, will be INTEGRATION if it's a base subscription
146
146
PREMIUM_SUBSCRIPTION_TIER = 5
147
- DRAFT_PREMIUM_SUBSCRIPTION_TIER = 5
147
+ DRAFT_PREMIUM_SUBSCRIPTION_TIER = 6
148
148
INTEGRATION = 7
149
149
CONNECTION = 8
150
+ UNKNOWN = 9
150
151
151
152
152
153
class RoleTags :
@@ -180,6 +181,7 @@ class RoleTags:
180
181
"_premium_subscriber" ,
181
182
"_available_for_purchase" ,
182
183
"_guild_connections" ,
184
+ "_is_guild_product_role" ,
183
185
"bot_id" ,
184
186
"_data" ,
185
187
"_type" ,
@@ -201,6 +203,8 @@ def __init__(self, data: RoleTagPayload):
201
203
self ._available_for_purchase : bool | None = _parse_tag_bool (
202
204
data , "available_for_purchase"
203
205
)
206
+ # here discord did things in a normal and logical way for once
207
+ self ._is_guild_product_role : bool | None = data .get ("is_guild_product_role" )
204
208
205
209
@cached_slot_property ("_type" )
206
210
def type (self ) -> RoleType :
@@ -214,28 +218,29 @@ def type(self) -> RoleType:
214
218
return RoleType .CONNECTION
215
219
216
220
# Paid roles
217
- if self ._guild_connections is False :
218
- if self . _premium_subscriber is False :
219
- return RoleType . GUILD_PRODUCT
220
-
221
- if self ._premium_subscriber is True :
222
- return RoleType .BOOSTER
223
-
224
- # subscription roles
225
- if self . integration_id is not None :
226
- if (
227
- self ._premium_subscriber is None
228
- and self .subscription_listing_id is not None
229
- ):
230
- if self ._available_for_purchase is True :
231
- return RoleType .PREMIUM_SUBSCRIPTION_TIER
232
- return RoleType .DRAFT_PREMIUM_SUBSCRIPTION_TIER
221
+ if self ._is_guild_product_role is True :
222
+ return RoleType . GUILD_PRODUCT
223
+
224
+ # Booster role
225
+ if self ._premium_subscriber is True :
226
+ return RoleType .BOOSTER
227
+
228
+ # subscription roles
229
+ if (
230
+ self . integration_id is not None
231
+ and self ._premium_subscriber is None
232
+ and self .subscription_listing_id is not None
233
+ ):
234
+ if self ._available_for_purchase is True :
235
+ return RoleType .PREMIUM_SUBSCRIPTION_TIER
236
+ return RoleType .DRAFT_PREMIUM_SUBSCRIPTION_TIER
233
237
234
238
# integration role (Twitch/YouTube)
235
239
if self .integration_id is not None :
236
240
return RoleType .INTEGRATION
237
241
238
- raise ValueError ("Unable to determine the role type based on provided tags." )
242
+ # Seeing how messed up this is it wouldn't be a surprise if this happened
243
+ return RoleType .UNKNOWN
239
244
240
245
@deprecated ("RoleTags.type" , "2.7" )
241
246
def is_bot_managed (self ) -> bool :
0 commit comments