Activities¶
This section documents everything related to User
’s and Member
’s activities.
Discord Models¶
Spotify¶
- class disnake.Spotify[source]¶
Represents a Spotify listening activity from Discord.
- x == y
Checks if two activities are equal.
- x != y
Checks if two activities are not equal.
- hash(x)
Returns the activity’s hash.
- str(x)
Returns the string ‘Spotify’.
- property type[source]¶
Returns the activity’s type. This is for compatibility with
Activity
.It always returns
ActivityType.listening
.- Type:
- property colour[source]¶
Returns the Spotify integration colour, as a
Colour
.There is an alias for this named
color
- Type:
- property color[source]¶
Returns the Spotify integration colour, as a
Colour
.There is an alias for this named
colour
- Type:
- property artist[source]¶
The artist of the song being played.
This does not attempt to split the artist information into multiple artists. Useful if there’s only a single artist.
- Type:
- property duration[source]¶
The duration of the song being played, if applicable.
Changed in version 2.6: This attribute can now be
None
.- Type:
Optional[
datetime.timedelta
]
- property created_at[source]¶
When the user started doing this activity in UTC.
New in version 1.3.
- Type:
Optional[
datetime.datetime
]
- property end[source]¶
When the user will stop doing this activity in UTC, if applicable.
Changed in version 2.6: This attribute can now be
None
.- Type:
Optional[
datetime.datetime
]
- property large_image_text[source]¶
Returns the large image asset hover text of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types.- Type:
Optional[
str
]
- property large_image_url[source]¶
Returns a URL pointing to the large image asset of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types. Additionally, supports dynamic asset urls using themp:
prefix now.- Type:
Optional[
str
]
- property small_image_text[source]¶
Returns the small image asset hover text of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types.- Type:
Optional[
str
]
- property small_image_url[source]¶
Returns a URL pointing to the small image asset of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types. Additionally, supports dynamic asset urls using themp:
prefix now.- Type:
Optional[
str
]
- property start[source]¶
When the user started doing this activity in UTC, if applicable.
Changed in version 2.6: This attribute can now be
None
.- Type:
Optional[
datetime.datetime
]
Data Classes¶
BaseActivity¶
- class disnake.BaseActivity(*, created_at=None, timestamps=None, assets=None, **kwargs)[source]¶
The base activity that all user-settable activities inherit from.
A user-settable activity is one that can be used in
Client.change_presence()
.The following types currently count as user-settable:
Note that although these types are considered user-settable by the library, Discord typically ignores certain combinations of activity depending on what is currently set. This behaviour may change in the future so there are no guarantees on whether Discord will actually let you set these types.
New in version 1.3.
- property created_at[source]¶
When the user started doing this activity in UTC.
New in version 1.3.
- Type:
Optional[
datetime.datetime
]
- property end[source]¶
When the user will stop doing this activity in UTC, if applicable.
Changed in version 2.6: This attribute can now be
None
.- Type:
Optional[
datetime.datetime
]
- property large_image_text[source]¶
Returns the large image asset hover text of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types.- Type:
Optional[
str
]
- property large_image_url[source]¶
Returns a URL pointing to the large image asset of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types. Additionally, supports dynamic asset urls using themp:
prefix now.- Type:
Optional[
str
]
- property small_image_text[source]¶
Returns the small image asset hover text of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types.- Type:
Optional[
str
]
- property small_image_url[source]¶
Returns a URL pointing to the small image asset of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types. Additionally, supports dynamic asset urls using themp:
prefix now.- Type:
Optional[
str
]
- property start[source]¶
When the user started doing this activity in UTC, if applicable.
Changed in version 2.6: This attribute can now be
None
.- Type:
Optional[
datetime.datetime
]
Activity¶
- class disnake.Activity(*, name=None, url=None, type=None, state=None, details=None, party=None, application_id=None, flags=None, buttons=None, emoji=None, id=None, platform=None, sync_id=None, session_id=None, **kwargs)[source]¶
Represents an activity in Discord.
This could be an activity such as streaming, playing, listening or watching.
For memory optimisation purposes, some activities are offered in slimmed down versions:
- Parameters:
name (Optional[
str
]) – The name of the activity.url (Optional[
str
]) – A stream URL that the activity could be doing.type (
ActivityType
) – The type of activity currently being done.
- type¶
The type of activity currently being done.
- Type:
- assets¶
A dictionary representing the images and their hover text of an activity. It contains the following optional keys:
large_image
: A string representing the ID for the large image asset.large_text
: A string representing the text when hovering over the large image asset.small_image
: A string representing the ID for the small image asset.small_text
: A string representing the text when hovering over the small image asset.
- Type:
- party¶
A dictionary representing the activity party. It contains the following optional keys:
id
: A string representing the party ID.size
: A list of two integers denoting (current_size, maximum_size).
- Type:
- buttons¶
A list of strings representing the labels of custom buttons shown in a rich presence.
New in version 2.0.
Changed in version 2.6: Changed type to
List[str]
to match API types.- Type:
List[str]
- emoji¶
The emoji that belongs to this activity.
- Type:
Optional[
PartialEmoji
]
- property created_at[source]¶
When the user started doing this activity in UTC.
New in version 1.3.
- Type:
Optional[
datetime.datetime
]
- property end[source]¶
When the user will stop doing this activity in UTC, if applicable.
Changed in version 2.6: This attribute can now be
None
.- Type:
Optional[
datetime.datetime
]
- property large_image_text[source]¶
Returns the large image asset hover text of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types.- Type:
Optional[
str
]
- property large_image_url[source]¶
Returns a URL pointing to the large image asset of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types. Additionally, supports dynamic asset urls using themp:
prefix now.- Type:
Optional[
str
]
- property small_image_text[source]¶
Returns the small image asset hover text of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types.- Type:
Optional[
str
]
- property small_image_url[source]¶
Returns a URL pointing to the small image asset of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types. Additionally, supports dynamic asset urls using themp:
prefix now.- Type:
Optional[
str
]
- property start[source]¶
When the user started doing this activity in UTC, if applicable.
Changed in version 2.6: This attribute can now be
None
.- Type:
Optional[
datetime.datetime
]
Game¶
- class disnake.Game(name, *, platform=None, **kwargs)[source]¶
A slimmed down version of
Activity
that represents a Discord game.This is typically displayed via Playing on the official Discord client.
- x == y
Checks if two games are equal.
- x != y
Checks if two games are not equal.
- hash(x)
Returns the game’s hash.
- str(x)
Returns the game’s name.
- Parameters:
name (
str
) – The game’s name.
- assets¶
A dictionary with the same structure as
Activity.assets
.- Type:
- property type[source]¶
Returns the game’s type. This is for compatibility with
Activity
.It always returns
ActivityType.playing
.- Type:
- property created_at[source]¶
When the user started doing this activity in UTC.
New in version 1.3.
- Type:
Optional[
datetime.datetime
]
- property end[source]¶
When the user will stop doing this activity in UTC, if applicable.
Changed in version 2.6: This attribute can now be
None
.- Type:
Optional[
datetime.datetime
]
- property large_image_text[source]¶
Returns the large image asset hover text of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types.- Type:
Optional[
str
]
- property large_image_url[source]¶
Returns a URL pointing to the large image asset of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types. Additionally, supports dynamic asset urls using themp:
prefix now.- Type:
Optional[
str
]
- property small_image_text[source]¶
Returns the small image asset hover text of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types.- Type:
Optional[
str
]
- property small_image_url[source]¶
Returns a URL pointing to the small image asset of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types. Additionally, supports dynamic asset urls using themp:
prefix now.- Type:
Optional[
str
]
- property start[source]¶
When the user started doing this activity in UTC, if applicable.
Changed in version 2.6: This attribute can now be
None
.- Type:
Optional[
datetime.datetime
]
Streaming¶
- class disnake.Streaming(*, name, url, details=None, state=None, **kwargs)[source]¶
A slimmed down version of
Activity
that represents a Discord streaming status.This is typically displayed via Streaming on the official Discord client.
- x == y
Checks if two streams are equal.
- x != y
Checks if two streams are not equal.
- hash(x)
Returns the stream’s hash.
- str(x)
Returns the stream’s name.
- platform¶
Where the user is streaming from (ie. YouTube, Twitch).
New in version 1.3.
- Type:
Optional[
str
]
- assets¶
A dictionary with the same structure as
Activity.assets
.- Type:
- property type[source]¶
Returns the game’s type. This is for compatibility with
Activity
.It always returns
ActivityType.streaming
.- Type:
- property twitch_name[source]¶
If provided, the twitch name of the user streaming.
This corresponds to the
large_image
key of theStreaming.assets
dictionary if it starts withtwitch:
. Typically set by the Discord client.- Type:
Optional[
str
]
- property created_at[source]¶
When the user started doing this activity in UTC.
New in version 1.3.
- Type:
Optional[
datetime.datetime
]
- property end[source]¶
When the user will stop doing this activity in UTC, if applicable.
Changed in version 2.6: This attribute can now be
None
.- Type:
Optional[
datetime.datetime
]
- property large_image_text[source]¶
Returns the large image asset hover text of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types.- Type:
Optional[
str
]
- property large_image_url[source]¶
Returns a URL pointing to the large image asset of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types. Additionally, supports dynamic asset urls using themp:
prefix now.- Type:
Optional[
str
]
- property small_image_text[source]¶
Returns the small image asset hover text of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types.- Type:
Optional[
str
]
- property small_image_url[source]¶
Returns a URL pointing to the small image asset of this activity, if applicable.
Changed in version 2.10: Moved from
Activity
to base type, making this available to all activity types. Additionally, supports dynamic asset urls using themp:
prefix now.- Type:
Optional[
str
]
- property start[source]¶
When the user started doing this activity in UTC, if applicable.
Changed in version 2.6: This attribute can now be
None
.- Type:
Optional[
datetime.datetime
]
CustomActivity¶
- class disnake.CustomActivity(name, *, emoji=None, state=None, **kwargs)[source]¶
Represents a Custom activity from Discord.
- x == y
Checks if two activities are equal.
- x != y
Checks if two activities are not equal.
- hash(x)
Returns the activity’s hash.
- str(x)
Returns the custom status text.
New in version 1.3.
- emoji¶
The emoji to pass to the activity, if any.
This currently cannot be set by bots.
- Type:
Optional[
PartialEmoji
]
- property type[source]¶
Returns the activity’s type. This is for compatibility with
Activity
.It always returns
ActivityType.custom
.- Type:
- property created_at[source]¶
When the user started doing this activity in UTC.
New in version 1.3.
- Type:
Optional[
datetime.datetime
]
- property end[source]¶
When the user will stop doing this activity in UTC, if applicable.
Changed in version 2.6: This attribute can now be
None
.- Type:
Optional[
datetime.datetime
]
- property start[source]¶
When the user started doing this activity in UTC, if applicable.
Changed in version 2.6: This attribute can now be
None
.- Type:
Optional[
datetime.datetime
]
Enumerations¶
ActivityType¶
- class disnake.ActivityType[source]¶
Specifies the type of
Activity
. This is used to check how to interpret the activity itself.- unknown¶
An unknown activity type. This should generally not happen.
- playing¶
A “Playing” activity type.
- streaming¶
A “Streaming” activity type.
- listening¶
A “Listening” activity type.
- watching¶
A “Watching” activity type.
- custom¶
A custom activity type.
- competing¶
A competing activity type.
New in version 1.5.
Status¶
- class disnake.Status[source]¶
Specifies a
Member
‘s status.- online¶
The member is online.
- offline¶
The member is offline.
- idle¶
The member is idle.
- dnd¶
The member is “Do Not Disturb”.
- invisible¶
The member is “invisible”. In reality, this is only used in sending a presence a la
Client.change_presence()
. When you receive a user’s presence this will beoffline
instead.
- streaming¶
The member is live streaming to Twitch or YouTube.
New in version 2.3.