From f8f8f418f3c51b6a885a1b6b7cd46c38c070b3bc Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 5 Mar 2018 11:01:46 -0500 Subject: 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. --- discord/state.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'discord/state.py') diff --git a/discord/state.py b/discord/state.py index d9a53886..731cb096 100644 --- a/discord/state.py +++ b/discord/state.py @@ -25,6 +25,7 @@ DEALINGS IN THE SOFTWARE. """ from .guild import Guild +from .activity import _ActivityTag from .user import User, ClientUser from .emoji import Emoji, PartialEmoji from .message import Message @@ -67,9 +68,12 @@ class ConnectionState: self.heartbeat_timeout = options.get('heartbeat_timeout', 60.0) self._listeners = [] - game = options.get('game', None) - if game: - game = dict(game) + activity = options.get('activity', None) + if activity: + if not isinstance(activity, _ActivityTag): + raise TypeError('activity parameter must be one of Game, Streaming, or Activity.') + + activity = activity.to_dict() status = options.get('status', None) if status: @@ -78,7 +82,7 @@ class ConnectionState: else: status = str(status) - self._game = game + self._activity = activity self._status = status self.clear() -- cgit v1.2.3