mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-16 18:59:09 +00:00
Add Game.type and Game.url attributes to change streaming status.
This commit is contained in:
parent
701720a0f8
commit
3feba5d1bb
@ -45,16 +45,31 @@ class Game:
|
|||||||
-----------
|
-----------
|
||||||
name : str
|
name : str
|
||||||
The game's name.
|
The game's name.
|
||||||
|
url : str
|
||||||
|
The game's URL. Usually used for twitch streaming.
|
||||||
|
type : int
|
||||||
|
The type of game being played. 1 indicates "Streaming".
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ['name']
|
__slots__ = ['name', 'type', 'url']
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.name = kwargs.get('name')
|
self.name = kwargs.get('name')
|
||||||
|
self.url = kwargs.get('url')
|
||||||
|
self.type = kwargs.get('type')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def _iterator(self):
|
||||||
|
for attr in self.__slots__:
|
||||||
|
value = getattr(self, attr, None)
|
||||||
|
if value is not None:
|
||||||
|
yield (attr, value)
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return self._iterator()
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return isinstance(other, Game) and other.name == self.name
|
return isinstance(other, Game) and other.name == self.name
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol):
|
|||||||
raise InvalidArgument('game must be of Game or None')
|
raise InvalidArgument('game must be of Game or None')
|
||||||
|
|
||||||
idle_since = None if idle == False else int(time.time() * 1000)
|
idle_since = None if idle == False else int(time.time() * 1000)
|
||||||
sent_game = game and {'name': game.name}
|
sent_game = dict(game) if game else None
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
'op': self.PRESENCE,
|
'op': self.PRESENCE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user