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.
state class-attribute instance-attribute #
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: ActivityType | int = attrs.field(
converter=ActivityType, default=ActivityType.PLAYING
)
The activity type.
url class-attribute instance-attribute #
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 #
The ID of the asset's large image, if set.
large_text class-attribute instance-attribute #
The text that'll appear when hovering over the large image, if set.
small_image class-attribute instance-attribute #
The ID of the asset's small image, if set.
small_text class-attribute instance-attribute #
The text that'll appear when hovering over the small image, if set.
make_large_image_url #
make_large_image_url(
*,
file_format: Literal[
"PNG", "JPEG", "JPG", "WEBP"
] = "PNG",
size: int = 4096,
lossless: bool = True,
) -> URL | None
Generate the large image asset URL for this application, if set.
If no large image is set or if the asset's dynamic URL (indicated by a {name}: prefix) is not known, this returns None.
Note
file_format, size, and lossless are ignored for images hosted outside of Discord or Discord's media proxy.
| PARAMETER | DESCRIPTION |
|---|---|
file_format | The format to use for this URL. Supports If not specified, the format will be TYPE: |
size | The size to set for the URL; Can be any power of two between TYPE: |
lossless | Whether to return a lossless or compressed WEBP image; This is ignored if TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Optional[URL] | The URL, or |
| RAISES | DESCRIPTION |
|---|---|
TypeError | If an invalid format is passed for |
ValueError | If |
RuntimeError | If |
make_small_image_url #
make_small_image_url(
*,
file_format: Literal[
"PNG", "JPEG", "JPG", "WEBP"
] = "PNG",
size: int = 4096,
lossless: bool = True,
) -> URL | None
Generate the small image asset URL for this application, if set.
If no small image is set or if the asset's dynamic URL (indicated by a {name}: prefix) is not known, this returns None.
Note
file_format, size, and lossless are ignored for images hosted outside of Discord or Discord's media proxy.
| PARAMETER | DESCRIPTION |
|---|---|
file_format | The format to use for this URL. Supports If not specified, the format will be TYPE: |
size | The size to set for the URL; Can be any power of two between TYPE: |
lossless | Whether to return a lossless or compressed WEBP image; This is ignored if TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Optional[URL] | The URL, or |
| RAISES | DESCRIPTION |
|---|---|
TypeError | If an invalid format is passed for |
ValueError | If |
RuntimeError | If |
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.
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.
ActivityParty #
ActivitySecret #
ActivityTimestamps #
The datetimes for the start and/or end of an activity session.
ActivityType #
Bases: int, Enum
The activity type.
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.
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.
ClientStatus #
MemberPresence #
Used to represent a guild member's presence.
activities class-attribute instance-attribute #
activities: Sequence[RichActivity] = attrs.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 = attrs.field(
repr=False,
eq=False,
hash=False,
metadata={attrs_extensions.SKIP_DEEP_COPY: True},
)
Client application that models may use for procedures.
client_status class-attribute instance-attribute #
client_status: ClientStatus = attrs.field(
eq=False, hash=False, repr=False
)
Platform-specific user-statuses.
guild_id class-attribute instance-attribute #
The ID of the guild this presence belongs to.
user_id class-attribute instance-attribute #
The ID of the user this presence belongs to.
visible_status class-attribute instance-attribute #
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 |
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 |
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 #
The ID of the application this activity is for, if applicable.
assets class-attribute instance-attribute #
assets: ActivityAssets | None = attrs.field(repr=False)
Images and their hover over text for the activity.
buttons class-attribute instance-attribute #
A sequence of up to 2 of the button labels shown in this rich presence.
created_at class-attribute instance-attribute #
When this activity was added to the user's session.
details class-attribute instance-attribute #
The text that describes what the activity's target is doing, if set.
emoji class-attribute instance-attribute #
The emoji of this activity, if it is a custom status and set.
flags class-attribute instance-attribute #
flags: ActivityFlag | None = attrs.field(repr=False)
Flags that describe what the activity includes, if present.
is_instance class-attribute instance-attribute #
Whether this activity is an instanced game session.
party class-attribute instance-attribute #
party: ActivityParty | None = attrs.field(repr=False)
Information about the party associated with this activity, if set.
secrets class-attribute instance-attribute #
secrets: ActivitySecret | None = attrs.field(repr=False)
Secrets for Rich Presence joining and spectating.
timestamps class-attribute instance-attribute #
timestamps: ActivityTimestamps | None = attrs.field(
repr=False
)
The timestamps for when this activity's current state will start and end, if applicable.