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/gateway.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'discord/gateway.py') diff --git a/discord/gateway.py b/discord/gateway.py index 6d535a38..7bd7c8de 100644 --- a/discord/gateway.py +++ b/discord/gateway.py @@ -30,7 +30,7 @@ import websockets import asyncio from . import utils, compat -from .game import Game +from .activity import create_activity, _ActivityTag from .errors import ConnectionClosed, InvalidArgument import logging import zlib, json @@ -283,10 +283,10 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol): payload['d']['shard'] = [self.shard_id, self.shard_count] state = self._connection - if state._game is not None or state._status is not None: + if state._activity is not None or state._status is not None: payload['d']['presence'] = { 'status': state._status, - 'game': state._game, + 'game': state._activity, 'since': 0, 'afk': False } @@ -469,19 +469,19 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol): raise ConnectionClosed(e, shard_id=self.shard_id) from e @asyncio.coroutine - def change_presence(self, *, game=None, status=None, afk=False, since=0.0): - if game is not None and not isinstance(game, Game): - raise InvalidArgument('game must be of type Game or None') + def change_presence(self, *, activity=None, status=None, afk=False, since=0.0): + if activity is not None: + if not isinstance(activity, _ActivityTag): + raise InvalidArgument('activity must be one of Game, Streaming, or Activity.') + activity = activity.to_dict() if status == 'idle': since = int(time.time() * 1000) - sent_game = dict(game) if game else None - payload = { 'op': self.PRESENCE, 'd': { - 'game': sent_game, + 'game': activity, 'afk': afk, 'since': since, 'status': status -- cgit v1.2.3