Skip to content

hikari.presences#

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

Activity #

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

name class-attribute instance-attribute #

name: str = field()

The activity name.

state class-attribute instance-attribute #

state: Optional[str] = field(default=None)

The activities state, if set.

This field can be use to set a custom status or provide more information on the activity.

type class-attribute instance-attribute #

type: Union[ActivityType, int] = field(converter=ActivityType, default=PLAYING)

The activity type.

url class-attribute instance-attribute #

url: Optional[str] = field(default=None, repr=False)

The activity URL, if set.

Only valid for hikari.presences.ActivityType.STREAMING activities.

ActivityAssets #

Used to represent possible assets for an activity.

large_image class-attribute instance-attribute #

large_image: Optional[str] = field(repr=False)

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

large_image_url property #

large_image_url: Optional[URL]

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.

large_text class-attribute instance-attribute #

large_text: Optional[str] = field(repr=True)

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

small_image class-attribute instance-attribute #

small_image: Optional[str] = field(repr=False)

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

small_image_url property #

small_image_url: Optional[URL]

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.

small_text class-attribute instance-attribute #

small_text: Optional[str] = field(repr=True)

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

make_large_image_url #

make_large_image_url(*, ext: str = 'png', size: int = 4096) -> Optional[URL]

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.

PARAMETER DESCRIPTION
ext

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

TYPE: str DEFAULT: 'png'

size

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

TYPE: int DEFAULT: 4096

RETURNS DESCRIPTION
Optional[URL]

The URL, or None if no icon exists.

RAISES DESCRIPTION
ValueError

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

RuntimeError

If hikari.presences.ActivityAssets.large_image points towards an unknown asset type.

make_small_image_url #

make_small_image_url(*, ext: str = 'png', size: int = 4096) -> Optional[URL]

Generate the small image asset URL for this application.

PARAMETER DESCRIPTION
ext

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

TYPE: str DEFAULT: 'png'

size

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

TYPE: int DEFAULT: 4096

RETURNS DESCRIPTION
Optional[URL]

The URL, or None if no icon exists.

RAISES DESCRIPTION
ValueError

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

RuntimeError

If hikari.presences.ActivityAssets.small_image points towards an unknown asset type.

ActivityFlag #

Bases: Flag

Flags that describe what an activity includes.

This can be more than one using bitwise-combinations.

EMBEDDED class-attribute instance-attribute #

EMBEDDED = 1 << 8

An activity that's embedded into a voice channel.

INSTANCE class-attribute instance-attribute #

INSTANCE = 1 << 0

Instance.

JOIN class-attribute instance-attribute #

JOIN = 1 << 1

Join.

JOIN_REQUEST class-attribute instance-attribute #

JOIN_REQUEST = 1 << 3

Join Request.

PARTY_PRIVACY_FRIENDS class-attribute instance-attribute #

PARTY_PRIVACY_FRIENDS = 1 << 6

Party privacy: friends only.

PARTY_PRIVACY_VOICE_CHANNEL class-attribute instance-attribute #

PARTY_PRIVACY_VOICE_CHANNEL = 1 << 7

Party privacy: voice channel only.

PLAY class-attribute instance-attribute #

PLAY = 1 << 5

Play.

SPECTATE class-attribute instance-attribute #

SPECTATE = 1 << 2

Spectate.

SYNC class-attribute instance-attribute #

SYNC = 1 << 4

Sync.

name property #

name: str

Return the name of the flag combination as a str.

value property #

value: int

Return the int value of the flag.

all #

all(*flags: Self) -> bool

Check if all of the given flags are part of this value.

RETURNS DESCRIPTION
bool

True if any of the given flags are part of this value. Otherwise, return False.

any #

any(*flags: Self) -> bool

Check if any of the given flags are part of this value.

RETURNS DESCRIPTION
bool

True if any of the given flags are part of this value. Otherwise, return False.

difference #

difference(other: Union[int, Self]) -> Self

Perform a set difference with the other set.

This will return all flags in this set that are not in the other value.

Equivalent to using the subtraction - operator.

intersection #

intersection(other: Union[int, Self]) -> Self

Return a combination of flags that are set for both given values.

Equivalent to using the "AND" & operator.

invert #

invert() -> Self

Return a set of all flags not in the current set.

is_disjoint #

is_disjoint(other: Union[int, Self]) -> bool

Return whether two sets have a intersection or not.

If the two sets have an intersection, then this returns False. If no common flag values exist between them, then this returns True.

is_subset #

is_subset(other: Union[int, Self]) -> bool

Return whether another set contains this set or not.

Equivalent to using the "in" operator.

is_superset #

is_superset(other: Union[int, Self]) -> bool

Return whether this set contains another set or not.

none #

none(*flags: Self) -> bool

Check if none of the given flags are part of this value.

Note

This is essentially the opposite of hikari.internal.enums.Flag.any.

RETURNS DESCRIPTION
bool

True if none of the given flags are part of this value. Otherwise, return False.

split #

split() -> Sequence[Self]

Return a list of all defined atomic values for this flag.

Any unrecognised bits will be omitted for brevity.

The result will be a name-sorted typing.Sequence of each member

symmetric_difference #

symmetric_difference(other: Union[int, Self]) -> Self

Return a set with the symmetric differences of two flag sets.

Equivalent to using the "XOR" ^ operator.

For a ^ b, this can be considered the same as (a - b) | (b - a).

union #

union(other: Union[int, Self]) -> Self

Return a combination of all flags in this set and the other set.

Equivalent to using the "OR" ~ operator.

ActivityParty #

Used to represent activity groups of users.

current_size class-attribute instance-attribute #

current_size: Optional[int] = field(eq=False, hash=False, repr=False)

Current size of this party, if applicable.

id class-attribute instance-attribute #

id: Optional[str] = field(hash=True, repr=True)

The string id of this party instance, if set.

max_size class-attribute instance-attribute #

max_size: Optional[int] = field(eq=False, hash=False, repr=False)

Maximum size of this party, if applicable.

ActivitySecret #

The secrets used for interacting with an activity party.

join class-attribute instance-attribute #

join: Optional[str] = field(repr=False)

The secret used for joining a party, if applicable.

match class-attribute instance-attribute #

match: Optional[str] = field(repr=False)

The secret used for matching a party, if applicable.

spectate class-attribute instance-attribute #

spectate: Optional[str] = field(repr=False)

The secret used for spectating a party, if applicable.

ActivityTimestamps #

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

end class-attribute instance-attribute #

end: Optional[datetime] = field(repr=True)

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

start class-attribute instance-attribute #

start: Optional[datetime] = field(repr=True)

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

ActivityType #

Bases: int, Enum

The activity type.

COMPETING class-attribute instance-attribute #

COMPETING = 5

Shows up as Competing in <name>.

CUSTOM class-attribute instance-attribute #

CUSTOM = 4

Shows up as <emoji> <name>.

Warning

As of the time of writing, emoji cannot be used by bot accounts.

LISTENING class-attribute instance-attribute #

LISTENING = 2

Shows up as Listening to <name>.

PLAYING class-attribute instance-attribute #

PLAYING = 0

Shows up as Playing <name>.

STREAMING class-attribute instance-attribute #

STREAMING = 1

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 class-attribute instance-attribute #

WATCHING = 3

Shows up as Watching <name>.

name property #

name: str

Return the name of the enum member as a str.

value property #

value

Return the value of the enum member.

ClientStatus #

The client statuses for this member.

desktop class-attribute instance-attribute #

desktop: Union[Status, str] = field(repr=True)

The status of the target user's desktop session.

mobile class-attribute instance-attribute #

mobile: Union[Status, str] = field(repr=True)

The status of the target user's mobile session.

web class-attribute instance-attribute #

web: Union[Status, str] = field(repr=True)

The status of the target user's web session.

MemberPresence #

Used to represent a guild member's presence.

activities class-attribute instance-attribute #

activities: Sequence[RichActivity] = field(eq=False, hash=False, repr=False)

All active user activities.

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

app class-attribute instance-attribute #

app: RESTAware = field(
    repr=False, eq=False, hash=False, metadata={SKIP_DEEP_COPY: True}
)

Client application that models may use for procedures.

client_status class-attribute instance-attribute #

client_status: ClientStatus = field(eq=False, hash=False, repr=False)

Platform-specific user-statuses.

guild_id class-attribute instance-attribute #

guild_id: Snowflake = field(hash=True, repr=True)

The ID of the guild this presence belongs to.

user_id class-attribute instance-attribute #

user_id: Snowflake = field(repr=True, hash=True)

The ID of the user this presence belongs to.

visible_status class-attribute instance-attribute #

visible_status: Union[Status, str] = field(eq=False, hash=False, repr=True)

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

fetch_member async #

fetch_member() -> Member

Fetch the member this presence is for.

RETURNS DESCRIPTION
Member

The requested member.

RAISES DESCRIPTION
UnauthorizedError

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

NotFoundError

If the user is not found.

RateLimitTooLongError

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

InternalServerError

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

fetch_user async #

fetch_user() -> User

Fetch the user this presence is for.

RETURNS DESCRIPTION
User

The requested user.

RAISES DESCRIPTION
UnauthorizedError

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

NotFoundError

If the user is not found.

RateLimitTooLongError

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

InternalServerError

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

RichActivity #

Bases: Activity

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

application_id class-attribute instance-attribute #

application_id: Optional[Snowflake] = field(repr=False)

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

assets class-attribute instance-attribute #

assets: Optional[ActivityAssets] = field(repr=False)

Images and their hover over text for the activity.

buttons class-attribute instance-attribute #

buttons: Sequence[str] = field(repr=False)

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

created_at class-attribute instance-attribute #

created_at: datetime = field(repr=False)

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

details class-attribute instance-attribute #

details: Optional[str] = field(repr=False)

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

emoji class-attribute instance-attribute #

emoji: Optional[Emoji] = field(repr=False)

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

flags class-attribute instance-attribute #

flags: Optional[ActivityFlag] = field(repr=False)

Flags that describe what the activity includes, if present.

is_instance class-attribute instance-attribute #

is_instance: Optional[bool] = field(repr=False)

Whether this activity is an instanced game session.

name class-attribute instance-attribute #

name: str = field()

The activity name.

party class-attribute instance-attribute #

party: Optional[ActivityParty] = field(repr=False)

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

secrets class-attribute instance-attribute #

secrets: Optional[ActivitySecret] = field(repr=False)

Secrets for Rich Presence joining and spectating.

state class-attribute instance-attribute #

state: Optional[str] = field(default=None)

The activities state, if set.

This field can be use to set a custom status or provide more information on the activity.

timestamps class-attribute instance-attribute #

timestamps: Optional[ActivityTimestamps] = field(repr=False)

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

type class-attribute instance-attribute #

type: Union[ActivityType, int] = field(converter=ActivityType, default=PLAYING)

The activity type.

url class-attribute instance-attribute #

url: Optional[str] = field(default=None, repr=False)

The activity URL, if set.

Only valid for hikari.presences.ActivityType.STREAMING activities.

Status #

Bases: str, Enum

The status of a member.

DO_NOT_DISTURB class-attribute instance-attribute #

DO_NOT_DISTURB = 'dnd'

Do not disturb/red.

IDLE class-attribute instance-attribute #

IDLE = 'idle'

Idle/yellow.

OFFLINE class-attribute instance-attribute #

OFFLINE = 'offline'

Offline or invisible/grey.

ONLINE class-attribute instance-attribute #

ONLINE = 'online'

Online/green.

name property #

name: str

Return the name of the enum member as a str.

value property #

value

Return the value of the enum member.