diff options
| author | Rapptz <[email protected]> | 2018-03-05 11:01:46 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2018-03-05 11:15:49 -0500 |
| commit | f8f8f418f3c51b6a885a1b6b7cd46c38c070b3bc (patch) | |
| tree | 0f26ed361806cf4470b8d98b61f63d2055cf87d0 /discord/member.py | |
| parent | Update docstrings for channel.py (diff) | |
| download | discord.py-f8f8f418f3c51b6a885a1b6b7cd46c38c070b3bc.tar.xz discord.py-f8f8f418f3c51b6a885a1b6b7cd46c38c070b3bc.zip | |
Split Game object to separate Activity subtypes for Rich Presences.
This is a massive breaking change.
* All references to "game" have been renamed to "activity"
* Activity objects contain a majority of the rich presence information
* Game and Streaming are subtypes for memory optimisation purposes for
the more common cases.
* Introduce a more specialised read-only type, Spotify, for the
official Spotify integration to make it easier to use.
Diffstat (limited to 'discord/member.py')
| -rw-r--r-- | discord/member.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/discord/member.py b/discord/member.py index 319d252b..11bbfcf4 100644 --- a/discord/member.py +++ b/discord/member.py @@ -32,7 +32,7 @@ import discord.abc from . import utils from .user import BaseUser, User -from .game import Game +from .activity import create_activity from .permissions import Permissions from .enums import Status, try_enum from .colour import Colour @@ -137,25 +137,25 @@ class Member(discord.abc.Messageable, _BaseUser): Attributes ---------- - roles + roles: List[:class:`Role`] A :class:`list` of :class:`Role` that the member belongs to. Note that the first element of this list is always the default '@everyone' role. These roles are sorted by their position in the role hierarchy. - joined_at : `datetime.datetime` + joined_at: `datetime.datetime` A datetime object that specifies the date and time in UTC that the member joined the guild for the first time. status : :class:`Status` The member's status. There is a chance that the status will be a :class:`str` if it is a value that is not recognised by the enumerator. - game : :class:`Game` - The game that the user is currently playing. Could be None if no game is being played. - guild : :class:`Guild` + activity: Union[:class:`Game`, :class:`Streaming`, :class:`Activity`] + The activity that the user is currently doing. Could be None if no activity is being done. + guild: :class:`Guild` The guild that the member belongs to. - nick : Optional[:class:`str`] + nick: Optional[:class:`str`] The guild specific nickname of the user. """ - __slots__ = ('roles', 'joined_at', 'status', 'game', 'guild', 'nick', '_user', '_state') + __slots__ = ('roles', 'joined_at', 'status', 'activity', 'guild', 'nick', '_user', '_state') def __init__(self, *, data, guild, state): self._state = state @@ -164,8 +164,7 @@ class Member(discord.abc.Messageable, _BaseUser): self.joined_at = utils.parse_time(data.get('joined_at')) self._update_roles(data) self.status = Status.offline - game = data.get('game', {}) - self.game = Game(**game) if game else None + self.activity = create_activity(data.get('game')) self.nick = data.get('nick', None) def __str__(self): @@ -218,8 +217,8 @@ class Member(discord.abc.Messageable, _BaseUser): def _presence_update(self, data, user): self.status = try_enum(Status, data['status']) - game = data.get('game', {}) - self.game = Game(**game) if game else None + self.activity = create_activity(data.get('game')) + u = self._user u.name = user.get('username', u.name) u.avatar = user.get('avatar', u.avatar) |