hikari.impl.shard
#
Single-shard implementation for the V10 event gateway for Discord.
GatewayShardImpl #
GatewayShardImpl(*, compression: Optional[str] = shard.GatewayCompression.TRANSPORT_ZLIB_STREAM, dumps: JSONEncoder = data_binding.default_json_dumps, loads: JSONDecoder = data_binding.default_json_loads, initial_activity: Optional[Activity] = None, initial_idle_since: Optional[datetime] = None, initial_is_afk: bool = False, initial_status: Status = presences.Status.ONLINE, intents: Intents, large_threshold: int = 250, shard_id: int = 0, shard_count: int = 1, http_settings: HTTPSettings, proxy_settings: ProxySettings, data_format: str = shard.GatewayDataFormat.JSON, event_manager: EventManager, event_factory: EventFactory, token: str, url: str)
Bases: GatewayShard
Implementation of a V10 compatible gateway.
Note
If all four of initial_activity
, initial_idle_since
, initial_is_afk
, and initial_status
are not defined and left to their default values, then the presence will not be updated on startup at all. If any of these are specified, then any that are not specified will be set to sane defaults, which may change the previous status. This will only occur during startup, and is an artifact of how Discord manages these updates internally. All other calls to update the status of the shard will support partial updates.
PARAMETER | DESCRIPTION |
---|---|
token | The bot token to use. TYPE: |
url | The gateway URL to use. This should not contain a query-string or fragments. TYPE: |
event_manager | The event manager this shard should make calls to. TYPE: |
event_factory | The event factory this shard should use. TYPE: |
compression | Compression format to use for the shard. Only supported values are TYPE: |
dumps | The JSON encoder this application should use. TYPE: |
loads | The JSON decoder this application should use. TYPE: |
initial_activity | The initial activity to appear to have for this shard, or |
initial_idle_since | |
initial_is_afk | Whether to appear to be AFK or not on login. TYPE: |
initial_status | The initial status to set on login for the shard. |
intents | Collection of intents to use. TYPE: |
large_threshold | The number of members to have in a guild for it to be considered large. TYPE: |
shard_id | The shard ID. TYPE: |
shard_count | The shard count. TYPE: |
http_settings | The HTTP-related settings to use while negotiating a websocket. TYPE: |
proxy_settings | The proxy settings to use while negotiating a websocket. TYPE: |
data_format | Data format to use for inbound data. Only supported format is |
heartbeat_latency property
#
heartbeat_latency: float
Shard's most recent heartbeat latency.
If the information is not yet available, then this will be float('nan')
instead.
shard_count property
#
shard_count: int
Return the total number of shards expected in the entire application.
get_user_id #
get_user_id() -> Snowflake
Return the user ID.
RETURNS | DESCRIPTION |
---|---|
Snowflake | The user ID for the application user. |
join async
#
join() -> None
Wait indefinitely until the websocket closes.
This can be placed in a task and cancelled without affecting the websocket runtime itself.
request_guild_members async
#
request_guild_members(guild: SnowflakeishOr[PartialGuild], *, include_presences: UndefinedOr[bool] = undefined.UNDEFINED, query: str = '', limit: int = 0, users: UndefinedOr[SnowflakeishSequence[User]] = undefined.UNDEFINED, nonce: UndefinedOr[str] = undefined.UNDEFINED) -> None
Request for a guild chunk.
Note
To request the full list of members, set query
to ""
(empty string) and limit
to 0
.
PARAMETER | DESCRIPTION |
---|---|
guild | The guild to request chunk for. TYPE: |
include_presences | If provided, whether to request presences. TYPE: |
query | If not TYPE: |
limit | Maximum number of members to send matching the query. TYPE: |
users | If provided, the users to request for. TYPE: |
nonce | If provided, the nonce to be sent with guild chunks. TYPE: |
RAISES | DESCRIPTION |
---|---|
ValueError | If trying to specify |
MissingIntentError | When trying to request presences without the |
update_presence async
#
update_presence(*, idle_since: UndefinedNoneOr[datetime] = undefined.UNDEFINED, afk: UndefinedOr[bool] = undefined.UNDEFINED, activity: UndefinedNoneOr[Activity] = undefined.UNDEFINED, status: UndefinedOr[Status] = undefined.UNDEFINED) -> None
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.
PARAMETER | DESCRIPTION |
---|---|
idle_since | The datetime that the user started being idle. If undefined, this will not be changed. TYPE: |
afk | Whether to mark the user as AFK. If undefined, this will not be changed. TYPE: |
activity | The activity to appear to be playing. If undefined, this will not be changed. TYPE: |
status | The web status to show. If undefined, this will not be changed. TYPE: |
update_voice_state async
#
update_voice_state(guild: SnowflakeishOr[PartialGuild], channel: Optional[SnowflakeishOr[GuildVoiceChannel]], *, self_mute: UndefinedOr[bool] = undefined.UNDEFINED, self_deaf: UndefinedOr[bool] = undefined.UNDEFINED) -> None
Update the voice state for this shard in a given guild.
PARAMETER | DESCRIPTION |
---|---|
guild | The guild or guild ID to update the voice state for. TYPE: |
channel | The channel or channel ID to update the voice state for. If TYPE: |
self_mute | If specified and TYPE: |
self_deaf | If specified and TYPE: |