Activity
Represents a Discord activity.
Attributes metadata :
Metadata of the activity containing extra fields about itself.
The activity's type.
Properties
application_id
assets
color
created_at
details
discord_side_id
Returns the activity's Discord side id. If the activity implements id returns that, else tries to look it put from constants.
Returns
discord_side_id : str
emoji
end
Returns when the activity ended or will end if applicable.
Returns
start : None
, datetime
flags
id
image_large_url
Returns the activity's large asset image's url. If the activity has no large asset image, then returns None
.
This function is a shared property of Activity
-s.
Returns
url : None
, str
image_small_url
Returns the activity's small asset image's url. If the activity has no small asset image, then returns None
.
This function is a shared property of Activity
-s.
Returns
url : None
, str
name
party
secrets
session_id
spotify_album_cover_url
Returns the spotify activity's currently playing track's album's cover url if applicable.
Only applicable for spotify activities.
Returns
album_cover_url : None
, str
spotify_cover_id
If the user listens to spotify, returns it's spotify name.
Only applicable for spotify activities.
Returns
name : None
, str
spotify_track_duration
Returns the spotify activity's duration, or None
if not applicable.
Only applicable for spotify activities.
Returns
duration : None
, timedelta
spotify_track_id
Returns the song's identifier.
Only applicable for spotify activities.
Returns
track_id : None
, str
spotify_track_url
Returns url to the spotify activity's song.
Only applicable for spotify activities.
Returns
url : None
, str
start
Returns when the activity was started if applicable.
Returns
start : None
, datetime
state
sync_id
timestamps
twitch_name
If the user streams on twitch, returns it's twitch name.
Only applicable for stream activities.
Returns
name : None
, str
twitch_preview_image_url
Returns the activity's twitch preview image url.
Only applicable for stream activities.
Returns
preview_image_url : None
, str
url
youtube_preview_image_url
Returns the activity's youtube preview image url.
Only applicable for stream activities.
Returns
preview_image_url : None
, str
youtube_video_id
If the user streams on youtube, returns it's stream's respective video identifier.
Only applicable for stream activities.
Returns
video_id : None
, str
Methods
(...)
__new__Creates a new activity with the given parameters.
Parameter | Type | Optional | Keyword only | Default | Description |
---|---|---|---|---|---|
name |
|
| The name of the activity. | ||
activity_type |
| The type value of the activity. | |||
**keyword_parameters | Keyword parameters | Additional parameters to pass to the activity-type specific constructor. | |||
activity_id |
| The id of the activity. | |||
application_id |
| The id of the activity's application. | |||
assets |
| The activity's assets. | |||
created_at |
| When the activity was created. | |||
details |
| What the player is currently doing. | |||
flags |
| The flags of the activity. | |||
party |
| The activity's party. | |||
secrets |
| The activity's secrets. | |||
session_id |
| Spotify activity's session's id. | |||
state |
| The player's current party status. | |||
sync_id |
| The ID of the currently playing track of a spotify activity. | |||
timestamps | The activity's timestamps. | ||||
url |
| The url of the activity. Only twitch and youtube urls are supported. |
Raises
TypeError
- If a parameter's type is incorrect.
- If extra or unused parameters were given.
ValueError
- If a parameter's value is incorrect.
()
copyCopies the activity.
Returns
new : instance<type<self>>
(...)
copy_withCopies the activity with the given fields.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
activity_type |
| The type value of the activity. | ||
**keyword_parameters | Keyword parameters | Additional parameters to pass to the activity-type specific constructor. | ||
activity_id |
| The id of the activity. | ||
application_id |
| The id of the activity's application. | ||
assets |
| The activity's assets. | ||
created_at |
| When the activity was created. | ||
details |
| What the player is currently doing. | ||
flags |
| The flags of the activity. | ||
name |
| The name of the activity. | ||
party |
| The activity's party. | ||
secrets |
| The activity's secrets. | ||
session_id |
| Spotify activity's session's id. | ||
state |
| The player's current party status. | ||
sync_id |
| The ID of the currently playing track of a spotify activity. | ||
timestamps | The activity's timestamps. | |||
url |
| The url of the activity. Only twitch and youtube urls are supported. |
Returns
new : instance<type<self>>
Raises
TypeError
- If a parameter's type is incorrect.
- If extra or unused parameters were given.
ValueError
- If a parameter's value is incorrect.
(data)
from_dataCreates an activity from the json data sent by Discord.
If the data is None
returns ACTIVITY_UNKNOWN
.
Parameter | Type | Description |
---|---|---|
data |
| Activity data received from Discord. |
Returns
activity : Activity
(...)
image_large_url_asReturns the activity's large asset image's url. If the activity has no large asset image, then returns None
.
This function is a shared method of Activity
-s.
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
ext |
|
| The extension of the image's url. Can be any of: | |
size |
|
| The preferred minimal size of the image's url. |
Returns
url : None
, str
Raises
ValueError
If ext
, size
was not passed as any of the expected values.
(...)
image_small_url_asReturns the activity's small asset image's url. If the activity has no small asset image, then returns None
.
This function is a shared method of Activity
-s.
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
ext |
|
| The extension of the image's url. Can be any of: | |
size |
|
| The preferred minimal size of the image's url. |
Returns
url : None
, str
Raises
ValueError
If ext
, size
was not passed as any of the expected values.
(...)
to_dataConverts the activity to json serializable dictionary, which can be sent with bot account to change activity.
Parameter | Type | Optional | Keyword only | Default | Description |
---|---|---|---|---|---|
defaults |
|
| Whether fields with the default values should be included as well. | ||
include_internals |
|
| Whether internal fields, like id-s should be present as well. | ||
user |
|
| Whether not only bot compatible fields should be included. |
Returns
data : dict
of (str
, object
) items
(data)
_difference_update_attributesUpdates the activity and returns the changes in a dict
of (attribute-name
, old-value
) items.
Parameter | Type | Description |
---|---|---|
data |
| Data received from Discord. |
Returns
old_attributes : dict
of (str
, object
) items
All item in the returned dict is optional.
Returned Data Structure
Keys | Values |
---|---|
assets | None , ActivityAssets |
created_at | None , datetime |
details | None , str |
emoji | None , Emoji |
flags | ActivityFlag |
name | str |
metadata | ActivityMetadataBase |
party | None , ActivityParty |
secrets | None , ActivitySecrets |
session_id | None , str |
state | None , str |
sync_id | None , str |
timestamps | None , ActivityTimestamps |
type | ActivityType |
url | None , str |
(data)
_update_attributesUpdates the activity by overwriting it's old attributes.
Parameter | Type | Description |
---|---|---|
data |
| Data received from Discord. |
()
__eq__Returns whether the two activities are equal.
()
__getattr__Drops a rich attribute error.
()
__hash__Returns the activity's hash value.
()
__repr__Returns the activity's representation.