mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
Simplify RoleTag implementation for always-null attributes
This commit is contained in:
parent
68c929cddf
commit
980fe7b0f9
@ -89,9 +89,9 @@ class RoleTags:
|
|||||||
# This is different from other fields where "null" means "not there".
|
# This is different from other fields where "null" means "not there".
|
||||||
# So in this case, a value of None is the same as True.
|
# So in this case, a value of None is the same as True.
|
||||||
# Which means we would need a different sentinel.
|
# Which means we would need a different sentinel.
|
||||||
self._premium_subscriber: Optional[Any] = data.get('premium_subscriber', MISSING)
|
self._premium_subscriber: bool = data.get('premium_subscriber', MISSING) is None
|
||||||
self._available_for_purchase: Optional[Any] = data.get('available_for_purchase', MISSING)
|
self._available_for_purchase: bool = data.get('available_for_purchase', MISSING) is None
|
||||||
self._guild_connections: Optional[Any] = data.get('guild_connections', MISSING)
|
self._guild_connections: bool = data.get('guild_connections', MISSING) is None
|
||||||
|
|
||||||
def is_bot_managed(self) -> bool:
|
def is_bot_managed(self) -> bool:
|
||||||
""":class:`bool`: Whether the role is associated with a bot."""
|
""":class:`bool`: Whether the role is associated with a bot."""
|
||||||
@ -99,7 +99,7 @@ class RoleTags:
|
|||||||
|
|
||||||
def is_premium_subscriber(self) -> bool:
|
def is_premium_subscriber(self) -> bool:
|
||||||
""":class:`bool`: Whether the role is the premium subscriber, AKA "boost", role for the guild."""
|
""":class:`bool`: Whether the role is the premium subscriber, AKA "boost", role for the guild."""
|
||||||
return self._premium_subscriber is None
|
return self._premium_subscriber
|
||||||
|
|
||||||
def is_integration(self) -> bool:
|
def is_integration(self) -> bool:
|
||||||
""":class:`bool`: Whether the role is managed by an integration."""
|
""":class:`bool`: Whether the role is managed by an integration."""
|
||||||
@ -110,14 +110,14 @@ class RoleTags:
|
|||||||
|
|
||||||
.. versionadded:: 2.2
|
.. versionadded:: 2.2
|
||||||
"""
|
"""
|
||||||
return self._available_for_purchase is None
|
return self._available_for_purchase
|
||||||
|
|
||||||
def is_guild_connection(self) -> bool:
|
def is_guild_connection(self) -> bool:
|
||||||
""":class:`bool`: Whether the role is a guild's linked role.
|
""":class:`bool`: Whether the role is a guild's linked role.
|
||||||
|
|
||||||
.. versionadded:: 2.2
|
.. versionadded:: 2.2
|
||||||
"""
|
"""
|
||||||
return self._guild_connections is None
|
return self._guild_connections
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user