mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-11 04:17:58 +00:00
Add Activity.created_at
This commit is contained in:
parent
072cef3bb6
commit
0c97907832
@ -84,7 +84,15 @@ t.ActivityFlags = {
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
class _ActivityTag:
|
class _ActivityTag:
|
||||||
__slots__ = ()
|
__slots__ = ('_created_at',)
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
self._created_at = kwargs.pop('created_at')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def created_at(self):
|
||||||
|
""":class:`datetime.datetime`: When the user started doing this activity in UTC."""
|
||||||
|
return datetime.datetime.utcfromtimestamp(self._created_at / 1000)
|
||||||
|
|
||||||
class Activity(_ActivityTag):
|
class Activity(_ActivityTag):
|
||||||
"""Represents an activity in Discord.
|
"""Represents an activity in Discord.
|
||||||
@ -136,10 +144,11 @@ class Activity(_ActivityTag):
|
|||||||
- ``size``: A list of up to two integer elements denoting (current_size, maximum_size).
|
- ``size``: A list of up to two integer elements denoting (current_size, maximum_size).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ('state', 'details', 'timestamps', 'assets', 'party',
|
__slots__ = ('state', 'details', '_created_at', 'timestamps', 'assets', 'party',
|
||||||
'flags', 'sync_id', 'session_id', 'type', 'name', 'url', 'application_id')
|
'flags', 'sync_id', 'session_id', 'type', 'name', 'url', 'application_id')
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
self.state = kwargs.pop('state', None)
|
self.state = kwargs.pop('state', None)
|
||||||
self.details = kwargs.pop('details', None)
|
self.details = kwargs.pop('details', None)
|
||||||
self.timestamps = kwargs.pop('timestamps', {})
|
self.timestamps = kwargs.pop('timestamps', {})
|
||||||
@ -272,6 +281,7 @@ class Game(_ActivityTag):
|
|||||||
__slots__ = ('name', '_end', '_start')
|
__slots__ = ('name', '_end', '_start')
|
||||||
|
|
||||||
def __init__(self, name, **extra):
|
def __init__(self, name, **extra):
|
||||||
|
super().__init__(**extra)
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -381,6 +391,7 @@ class Streaming(_ActivityTag):
|
|||||||
__slots__ = ('name', 'url', 'details', 'assets')
|
__slots__ = ('name', 'url', 'details', 'assets')
|
||||||
|
|
||||||
def __init__(self, *, name, url, **extra):
|
def __init__(self, *, name, url, **extra):
|
||||||
|
super().__init__(**extra)
|
||||||
self.name = name
|
self.name = name
|
||||||
self.url = url
|
self.url = url
|
||||||
self.details = extra.pop('details', None)
|
self.details = extra.pop('details', None)
|
||||||
@ -458,7 +469,8 @@ class Spotify:
|
|||||||
Returns the string 'Spotify'.
|
Returns the string 'Spotify'.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ('_state', '_details', '_timestamps', '_assets', '_party', '_sync_id', '_session_id')
|
__slots__ = ('_state', '_details', '_timestamps', '_assets', '_party', '_sync_id', '_session_id',
|
||||||
|
'_created_at')
|
||||||
|
|
||||||
def __init__(self, **data):
|
def __init__(self, **data):
|
||||||
self._state = data.pop('state', None)
|
self._state = data.pop('state', None)
|
||||||
@ -468,6 +480,7 @@ class Spotify:
|
|||||||
self._party = data.pop('party', {})
|
self._party = data.pop('party', {})
|
||||||
self._sync_id = data.pop('sync_id')
|
self._sync_id = data.pop('sync_id')
|
||||||
self._session_id = data.pop('session_id')
|
self._session_id = data.pop('session_id')
|
||||||
|
self._created_at = data.pop('created_at')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def type(self):
|
def type(self):
|
||||||
@ -477,6 +490,11 @@ class Spotify:
|
|||||||
"""
|
"""
|
||||||
return ActivityType.listening
|
return ActivityType.listening
|
||||||
|
|
||||||
|
@property
|
||||||
|
def created_at(self):
|
||||||
|
""":class:`datetime.datetime`: When the user started listening in UTC."""
|
||||||
|
return datetime.datetime.utcfromtimestamp(self._created_at / 1000)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def colour(self):
|
def colour(self):
|
||||||
"""Returns the Spotify integration colour, as a :class:`Colour`.
|
"""Returns the Spotify integration colour, as a :class:`Colour`.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user