diff options
| author | Rapptz <[email protected]> | 2015-10-14 18:54:45 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2015-10-14 18:54:45 -0400 |
| commit | a130706f2334187a774341a044e02e697e7f80d2 (patch) | |
| tree | eadee0c0b38b391a67417a1de4ea34b925cfadfc | |
| parent | Message.author is now either Member or User. (diff) | |
| download | discord.py-a130706f2334187a774341a044e02e697e7f80d2.tar.xz discord.py-a130706f2334187a774341a044e02e697e7f80d2.zip | |
Add Client.change_status.
| -rw-r--r-- | discord/client.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/discord/client.py b/discord/client.py index c144e742..6e8872ff 100644 --- a/discord/client.py +++ b/discord/client.py @@ -1023,3 +1023,33 @@ class Client(object): response = requests.delete(url, headers=self.headers) log.debug(request_logging_format.format(response=response, name='delete_role')) return is_response_successful(response) + + def change_status(self, game_id=None, idle=False): + """Changes the client's status. + + The game_id parameter is a numeric ID (not a string) that represents + a game being played currently. The list of game_id to actual games changes + constantly and would thus be out of date pretty quickly. An old version of + the game_id database can be seen `here`_ to help you get started. + + The idle parameter is a boolean parameter that indicates whether the + client should go idle or not. + + .. _here: https://gist.github.com/Rapptz/a82b82381b70a60c281b + + :param game_id: The numeric game ID being played. None if no game is being played. + :param idle: A boolean indicating if the client should go idle.""" + + idle_since = None if idle == False else int(time.time() * 1000) + payload = { + 'op': 3, + 'd': { + 'game_id': game_id, + 'idle_since': idle_since + } + } + + sent = json.dumps(payload) + log.debug('Sending "{}" to change status'.format(sent)) + self.ws.send(sent) + |