aboutsummaryrefslogtreecommitdiff
path: root/discord/gateway.py
diff options
context:
space:
mode:
Diffstat (limited to 'discord/gateway.py')
-rw-r--r--discord/gateway.py18
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