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.
- class hikari.api.shard.GatewayDataFormat[source]#
Bases:
str
,hikari.internal.enums.Enum
Format of inbound gateway payloads.
- 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 intents: hikari.intents.Intents[source]#
Intents set on this shard.
- abstract property shard_count: int[source]#
Return the total number of shards expected in the entire application.
- 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) andlimit
to0
.- Parameters:
- guild
hikari.guilds.Guild
The guild to request chunk for.
- guild
- Other Parameters:
- include_presences
hikari.undefined.UndefinedOr
[bool] If provided, whether to request presences.
- query
str
If not
""
, request the members which username starts with the string.- limit
int
Maximum number of members to send matching the query.
- users
hikari.undefined.UndefinedOr
[hikari.snowflakes.SnowflakeishSequence
[hikari.users.User
]] If provided, the users to request for.
- nonce
hikari.undefined.UndefinedOr
[str
] If provided, the nonce to be sent with guild chunks.
- include_presences
- Raises:
ValueError
When trying to specify
users
withquery
/limit
, iflimit
is not between 0 and 100, both inclusive or ifusers
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 withoutGUILD_PRESENCES
.
- 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_since
hikari.undefined.UndefinedNoneOr
[datetime.datetime
] The datetime that the user started being idle. If undefined, this will not be changed.
- afk
hikari.undefined.UndefinedOr
[bool] If
True
, the user is marked as AFK. IfFalse
, the user is marked as being active. If undefined, this will not be changed.- activity
hikari.undefined.UndefinedNoneOr
[hikari.presences.Activity
] The activity to appear to be playing. If undefined, this will not be changed.
- status
hikari.undefined.UndefinedOr
[hikari.presences.Status
] The web status to show. If undefined, this will not be changed.
- idle_since
- 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:
- guild
hikari.snowflakes.SnowflakeishOr
[hikari.guilds.PartialGuild
] The guild or guild ID to update the voice state for.
- channel
typing.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. IfFalse
, then it will unmute itself.- self_deafbool
If specified and
True
, the bot will deafen itself in that voice channel. IfFalse
, then it will undeafen itself.
- guild