Add PremiumType enumeration and ClientUser.premium_type
This commit is contained in:
parent
9765b701f2
commit
79f172cf80
@ -29,7 +29,8 @@ from enum import Enum, IntEnum
|
|||||||
__all__ = ['ChannelType', 'MessageType', 'VoiceRegion', 'SpeakingState',
|
__all__ = ['ChannelType', 'MessageType', 'VoiceRegion', 'SpeakingState',
|
||||||
'VerificationLevel', 'ContentFilter', 'Status', 'DefaultAvatar',
|
'VerificationLevel', 'ContentFilter', 'Status', 'DefaultAvatar',
|
||||||
'RelationshipType', 'AuditLogAction', 'AuditLogActionCategory',
|
'RelationshipType', 'AuditLogAction', 'AuditLogActionCategory',
|
||||||
'UserFlags', 'ActivityType', 'HypeSquadHouse', 'NotificationLevel']
|
'UserFlags', 'ActivityType', 'HypeSquadHouse', 'NotificationLevel',
|
||||||
|
'PremiumType']
|
||||||
|
|
||||||
class ChannelType(Enum):
|
class ChannelType(Enum):
|
||||||
text = 0
|
text = 0
|
||||||
@ -245,6 +246,10 @@ class HypeSquadHouse(Enum):
|
|||||||
brilliance = 2
|
brilliance = 2
|
||||||
balance = 3
|
balance = 3
|
||||||
|
|
||||||
|
class PremiumType(Enum):
|
||||||
|
nitro_classic = 1
|
||||||
|
nitro = 2
|
||||||
|
|
||||||
def try_enum(cls, val):
|
def try_enum(cls, val):
|
||||||
"""A function that tries to turn the value into enum ``cls``.
|
"""A function that tries to turn the value into enum ``cls``.
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ from collections import namedtuple
|
|||||||
|
|
||||||
import discord.abc
|
import discord.abc
|
||||||
from .utils import snowflake_time, _bytes_to_base64_data, parse_time, valid_icon_size
|
from .utils import snowflake_time, _bytes_to_base64_data, parse_time, valid_icon_size
|
||||||
from .enums import DefaultAvatar, RelationshipType, UserFlags, HypeSquadHouse
|
from .enums import DefaultAvatar, RelationshipType, UserFlags, HypeSquadHouse, PremiumType, try_enum
|
||||||
from .errors import ClientException, InvalidArgument
|
from .errors import ClientException, InvalidArgument
|
||||||
from .colour import Colour
|
from .colour import Colour
|
||||||
|
|
||||||
@ -299,8 +299,10 @@ class ClientUser(BaseUser):
|
|||||||
Specifies if the user has MFA turned on and working.
|
Specifies if the user has MFA turned on and working.
|
||||||
premium: :class:`bool`
|
premium: :class:`bool`
|
||||||
Specifies if the user is a premium user (e.g. has Discord Nitro).
|
Specifies if the user is a premium user (e.g. has Discord Nitro).
|
||||||
|
premium_type: :class:`PremiumType`
|
||||||
|
Specifies the type of premium a user has (e.g. Nitro or Nitro Classic). Could be None if the user is not premium.
|
||||||
"""
|
"""
|
||||||
__slots__ = ('email', 'verified', 'mfa_enabled', 'premium', '_relationships')
|
__slots__ = ('email', 'verified', 'mfa_enabled', 'premium', 'premium_type', '_relationships')
|
||||||
|
|
||||||
def __init__(self, *, state, data):
|
def __init__(self, *, state, data):
|
||||||
super().__init__(state=state, data=data)
|
super().__init__(state=state, data=data)
|
||||||
@ -308,6 +310,7 @@ class ClientUser(BaseUser):
|
|||||||
self.email = data.get('email')
|
self.email = data.get('email')
|
||||||
self.mfa_enabled = data.get('mfa_enabled', False)
|
self.mfa_enabled = data.get('mfa_enabled', False)
|
||||||
self.premium = data.get('premium', False)
|
self.premium = data.get('premium', False)
|
||||||
|
self.premium_type = try_enum(PremiumType, data.get('premium_type', None))
|
||||||
self._relationships = {}
|
self._relationships = {}
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user