hikari.api.shard#

Provides an interface for gateway shard implementations to conform to.

Module Contents#

class hikari.api.shard.GatewayCompression[source]#

Bases: str, hikari.internal.enums.Enum

Types of gateway compression that may be supported.

PAYLOAD_ZLIB_STREAM = 'payload_zlib_stream'[source]#

Payload compression using ZLIB.

TRANSPORT_ZLIB_STREAM = 'transport_zlib_stream'[source]#

Transport compression using ZLIB.

class hikari.api.shard.GatewayDataFormat[source]#

Bases: str, hikari.internal.enums.Enum

Format of inbound gateway payloads.

ETF = 'etf'[source]#

Erlang transmission format.

JSON = 'json'[source]#

Javascript serialized object notation.

class hikari.api.shard.GatewayShard[source]#

Bases: abc.ABC

Interface for a definition of a v10 compatible websocket gateway.

Each instance should represent a single shard.

abstract property heartbeat_latency: float[source]#

Shard’s most recent heartbeat latency.

If the information is not yet available, then this will be float('nan') instead.

abstract property id: int[source]#

0-based shard ID for this shard.

abstract property intents: hikari.intents.Intents[source]#

Intents set on this shard.

abstract property is_alive: bool[source]#

Whether the shard is alive.

abstract property is_connected: bool[source]#

Whether the shard is connected.

abstract property shard_count: int[source]#

Return the total number of shards expected in the entire application.

abstract async close()[source]#

Close the websocket if it is connected.

abstract get_user_id()[source]#

Return the user ID.

Returns:
hikari.snowflakes.Snowflake

The user ID for the application user.

abstract async join()[source]#

Wait indefinitely until the websocket closes.

This can be placed in a task and cancelled without affecting the websocket runtime itself.

abstract async request_guild_members(guild, *, include_presences=undefined.UNDEFINED, query='', limit=0, users=undefined.UNDEFINED, nonce=undefined.UNDEFINED)[source]#

Request for a guild chunk.

Note

To request the full list of members, set query to "" (empty string) and limit to 0.

Parameters:
guildhikari.guilds.Guild

The guild to request chunk for.

Other Parameters:
include_presenceshikari.undefined.UndefinedOr[bool]

If provided, whether to request presences.

querystr

If not "", request the members which username starts with the string.

limitint

Maximum number of members to send matching the query.

usershikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishSequence[hikari.users.User]]

If provided, the users to request for.

noncehikari.undefined.UndefinedOr[str]

If provided, the nonce to be sent with guild chunks.

Raises:
ValueError

When trying to specify users with query/limit, if limit is not between 0 and 100, both inclusive or if users length is over 100.

hikari.errors.MissingIntentError

When trying to request presences without the GUILD_MEMBERS or when trying to request the full list of members without GUILD_PRESENCES.

abstract async start()[source]#

Start the shard, wait for it to become ready.

abstract async update_presence(*, idle_since=undefined.UNDEFINED, afk=undefined.UNDEFINED, activity=undefined.UNDEFINED, status=undefined.UNDEFINED)[source]#

Update the presence of the shard user.

If the shard is not alive, no physical data will be sent, however, the new presence settings will be remembered for when the shard does connect.

Other Parameters:
idle_sincehikari.undefined.UndefinedNoneOr[datetime.datetime]

The datetime that the user started being idle. If undefined, this will not be changed.

afkhikari.undefined.UndefinedOr[bool]

If True, the user is marked as AFK. If False, the user is marked as being active. If undefined, this will not be changed.

activityhikari.undefined.UndefinedNoneOr[hikari.presences.Activity]

The activity to appear to be playing. If undefined, this will not be changed.

statushikari.undefined.UndefinedOr[hikari.presences.Status]

The web status to show. If undefined, this will not be changed.

abstract async update_voice_state(guild, channel, *, self_mute=undefined.UNDEFINED, self_deaf=undefined.UNDEFINED)[source]#

Update the voice state for this shard in a given guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

The guild or guild ID to update the voice state for.

channeltyping.Optional[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildVoiceChannel]]

The channel or channel ID to update the voice state for. If None then the bot will leave the voice channel that it is in for the given guild.

self_mutebool

If specified and True, the bot will mute itself in that voice channel. If False, then it will unmute itself.

self_deafbool

If specified and True, the bot will deafen itself in that voice channel. If False, then it will undeafen itself.