hikari.presences#

Application and entities that are used to describe guilds on Discord.

Module Contents#

class hikari.presences.Activity[source]#

Represents a regular activity that can be associated with a presence.

name: str[source]#

The activity name.

type: ActivityType | int[source]#

The activity type.

url: str | None[source]#

The activity URL. Only valid for STREAMING activities.

class hikari.presences.ActivityAssets[source]#

Used to represent possible assets for an activity.

property large_image_url: hikari.files.URL | None[source]#

Large image asset URL.

Note

This will be None if no large image asset exists or if the asset’s dynamic URL (indicated by a {name}: prefix) is not known.

property small_image_url: hikari.files.URL | None[source]#

Small image asset URL.

Note

This will be None if no large image asset exists or if the asset’s dynamic URL (indicated by a {name}: prefix) is not known.

large_image: str | None[source]#

The ID of the asset’s large image, if set.

large_text: str | None[source]#

The text that’ll appear when hovering over the large image, if set.

small_image: str | None[source]#

The ID of the asset’s small image, if set.

small_text: str | None[source]#

The text that’ll appear when hovering over the small image, if set.

make_large_image_url(*, ext='png', size=4096)[source]#

Generate the large image asset URL for this application.

Note

ext and size are ignored for images hosted outside of Discord or on Discord’s media proxy.

Parameters:
extstr

The extension to use for this URL, defaults to png. Supports png, jpeg, jpg and webp.

sizeint

The size to set for the URL, defaults to 4096. Can be any power of two between 16 and 4096.

Returns:
typing.Optional[hikari.files.URL]

The URL, or None if no icon exists.

Raises:
ValueError

If the size is not an integer power of 2 between 16 and 4096 (inclusive).

RuntimeError

If ActivityAssets.large_image points towards an unknown asset type.

make_small_image_url(*, ext='png', size=4096)[source]#

Generate the small image asset URL for this application.

Parameters:
extstr

The extension to use for this URL, defaults to png. Supports png, jpeg, jpg and webp.

sizeint

The size to set for the URL, defaults to 4096. Can be any power of two between 16 and 4096.

Returns:
typing.Optional[hikari.files.URL]

The URL, or None if no icon exists.

Raises:
ValueError

If the size is not an integer power of 2 between 16 and 4096 (inclusive).

RuntimeError

If ActivityAssets.small_image points towards an unknown asset type.

class hikari.presences.ActivityFlag[source]#

Bases: hikari.internal.enums.Flag

Flags that describe what an activity includes.

This can be more than one using bitwise-combinations.

EMBEDDED[source]#

An activity that’s embedded into a voice channel.

INSTANCE[source]#

Instance.

JOIN[source]#

Join.

JOIN_REQUEST[source]#

Join Request.

PARTY_PRIVACY_FRIENDS[source]#

Party privacy: friends only.

PARTY_PRIVACY_VOICE_CHANNEL[source]#

Party privacy: voice channel only.

PLAY[source]#

Play.

SPECTATE[source]#

Spectate.

SYNC[source]#

Sync.

class hikari.presences.ActivityParty[source]#

Used to represent activity groups of users.

current_size: int | None[source]#

Current size of this party, if applicable.

id: str | None[source]#

The string id of this party instance, if set.

max_size: int | None[source]#

Maximum size of this party, if applicable.

class hikari.presences.ActivitySecret[source]#

The secrets used for interacting with an activity party.

join: str | None[source]#

The secret used for joining a party, if applicable.

match: str | None[source]#

The secret used for matching a party, if applicable.

spectate: str | None[source]#

The secret used for spectating a party, if applicable.

class hikari.presences.ActivityTimestamps[source]#

The datetimes for the start and/or end of an activity session.

end: datetime.datetime | None[source]#

When this activity’s session will end, if applicable.

start: datetime.datetime | None[source]#

When this activity’s session was started, if applicable.

class hikari.presences.ActivityType[source]#

Bases: int, hikari.internal.enums.Enum

The activity type.

COMPETING = 5[source]#

Shows up as Competing in.

CUSTOM = 4[source]#

A custom status.

To set an emoji with the status, place a unicode emoji or Discord emoji (:smiley:) as the first part of the status activity name.

Warning

Bots DO NOT support setting custom statuses.

LISTENING = 2[source]#

Shows up as Listening to.

PLAYING = 0[source]#

Shows up as Playing.

STREAMING = 1[source]#

Shows up as Streaming and links to a Twitch or YouTube stream/video.

Warning

You MUST provide a valid Twitch or YouTube stream URL to the activity you create in order for this to be valid. If you fail to do this, then the activity WILL NOT update.

WATCHING = 3[source]#

Shows up as Watching.

class hikari.presences.ClientStatus[source]#

The client statuses for this member.

desktop: Status | str[source]#

The status of the target user’s desktop session.

mobile: Status | str[source]#

The status of the target user’s mobile session.

web: Status | str[source]#

The status of the target user’s web session.

class hikari.presences.MemberPresence[source]#

Used to represent a guild member’s presence.

activities: Sequence[RichActivity][source]#

All active user activities.

You can assume the first activity is the one that the GUI Discord client will show.

app: hikari.traits.RESTAware[source]#

Client application that models may use for procedures.

client_status: ClientStatus[source]#

Platform-specific user-statuses.

guild_id: hikari.snowflakes.Snowflake[source]#

The ID of the guild this presence belongs to.

user_id: hikari.snowflakes.Snowflake[source]#

The ID of the user this presence belongs to.

visible_status: Status | str[source]#

This user’s current status being displayed by the client.

async fetch_member()[source]#

Fetch the member this presence is for.

Returns:
hikari.guilds.Member

The requested member.

Raises:
hikari.errors.UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

hikari.errors.NotFoundError

If the user is not found.

hikari.errors.RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

hikari.errors.InternalServerError

If an internal error occurs on Discord while handling the request.

async fetch_user()[source]#

Fetch the user this presence is for.

Returns:
hikari.users.User

The requested user.

Raises:
hikari.errors.UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

hikari.errors.NotFoundError

If the user is not found.

hikari.errors.RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

hikari.errors.InternalServerError

If an internal error occurs on Discord while handling the request.

class hikari.presences.RichActivity[source]#

Bases: Activity

Represents a rich activity that can be associated with a presence.

application_id: hikari.snowflakes.Snowflake | None[source]#

The ID of the application this activity is for, if applicable.

assets: ActivityAssets | None[source]#

Images and their hover over text for the activity.

buttons: Sequence[str][source]#

A sequence of up to 2 of the button labels shown in this rich presence.

created_at: datetime.datetime[source]#

When this activity was added to the user’s session.

details: str | None[source]#

The text that describes what the activity’s target is doing, if set.

emoji: hikari.emojis.Emoji | None[source]#

The emoji of this activity, if it is a custom status and set.

flags: ActivityFlag | None[source]#

Flags that describe what the activity includes, if present.

is_instance: bool | None[source]#

Whether this activity is an instanced game session.

party: ActivityParty | None[source]#

Information about the party associated with this activity, if set.

secrets: ActivitySecret | None[source]#

Secrets for Rich Presence joining and spectating.

state: str | None[source]#

The current status of this activity’s target, if set.

timestamps: ActivityTimestamps | None[source]#

The timestamps for when this activity’s current state will start and end, if applicable.

class hikari.presences.Status[source]#

Bases: str, hikari.internal.enums.Enum

The status of a member.

DO_NOT_DISTURB = 'dnd'[source]#

Do not disturb/red.

IDLE = 'idle'[source]#

Idle/yellow.

OFFLINE = 'offline'[source]#

Offline or invisible/grey.

ONLINE = 'online'[source]#

Online/green.