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/shard.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/shard.py')
| -rw-r--r-- | discord/shard.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/discord/shard.py b/discord/shard.py index b29e45d0..284f5cdc 100644 --- a/discord/shard.py +++ b/discord/shard.py @@ -307,18 +307,24 @@ class AutoShardedClient(Client): yield from self.http.close() @asyncio.coroutine - def change_presence(self, *, game=None, status=None, afk=False, shard_id=None): + def change_presence(self, *, activity=None, status=None, afk=False, shard_id=None): """|coro| Changes the client's presence. - The game parameter is a Game object (not a string) that represents - a game being played currently. + The activity parameter is a :class:`Activity` object (not a string) that represents + the activity being done currently. This could also be the slimmed down versions, + :class:`Game` and :class:`Streaming`. + + Example: :: + + game = discord.Game("with the API") + await client.change_presence(status=discord.Status.idle, activity=game) Parameters ---------- - game: Optional[:class:`Game`] - The game being played. None if no game is being played. + activity: Optional[Union[:class:`Game`, :class:`Streaming`, :class:`Activity`]] + The activity being done. ``None`` if no currently active activity is done. status: Optional[:class:`Status`] Indicates what status to change to. If None, then :attr:`Status.online` is used. @@ -334,7 +340,7 @@ class AutoShardedClient(Client): Raises ------ InvalidArgument - If the ``game`` parameter is not :class:`Game` or None. + If the ``activity`` parameter is not of proper type. """ if status is None: @@ -349,12 +355,12 @@ class AutoShardedClient(Client): if shard_id is None: for shard in self.shards.values(): - yield from shard.ws.change_presence(game=game, status=status, afk=afk) + yield from shard.ws.change_presence(activity=activity, status=status, afk=afk) guilds = self._connection.guilds else: shard = self.shards[shard_id] - yield from shard.ws.change_presence(game=game, status=status, afk=afk) + yield from shard.ws.change_presence(activity=activity, status=status, afk=afk) guilds = [g for g in self._connection.guilds if g.shard_id == shard_id] for guild in guilds: @@ -362,5 +368,5 @@ class AutoShardedClient(Client): if me is None: continue - me.game = game + me.activity = activity me.status = status_enum |