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/gateway.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/gateway.py')
| -rw-r--r-- | discord/gateway.py | 18 |
1 files changed, 9 insertions, 9 deletions
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 |