DiscordGatewayClientBase

Base gateway for clients.

Properties

latency

The latency of the websocket in seconds. If no latency is recorded will return the default latency.

Returns

latency : float

Methods

__new__()

Creates a new gateway

abort()

Abort the gateway immediately.

beat()

Sends a heartbeat packet to Discord.

This method is a coroutine.

change_voice_state(guild_id, channel_id, ...)

Sends a VOICE_STATE packet to Discord.

This method is a coroutine.

ParameterTypeOptionalKeyword onlyDefaultDescription
guild_id

int

The voice client's guild's id.

channel_id

int

The voice client's channel's id.

self_deaf

bool

False

Whether the voice client is deafen.

self_mute

bool

False

Whether the voice client is muted.

close()

Cancels the gateway's heartbeat and closes it's websocket with close code of 1000.

This method is a coroutine.

get_gateway(guild_id)

Returns the gateway for the given guild_id.

ParameterTypeDescription
guild_id

int

The guild's identifier to get the gateway for. Can be 0.

Returns

gateway : DiscordGatewayClientBase

run()

Keeps the gateway receiving message and processing it. If the gateway needs to be reconnected, reconnects itself. If connecting cannot succeed, because there is no internet returns True. If the .client is stopped, then returns False.

If True is returned the respective client stops all other gateways as well and tries to reconnect. When the internet is back the client will launch back the gateway.

This method is a coroutine.

Returns

outcome : bool<False>

Always False.

Raises

DiscordGatewayException

The client tries to connect with bad or not acceptable intent or shard value.

DiscordException

send_as_json(data)

Sends the data as json to Discord on the gateway's websocket. If there is no websocket, or the websocket is closed will not raise.

This method is a coroutine.

ParameterTypeDescription
data

object

The data to send.

terminate()

Terminates the gateway's beating and closes it's websocket with close code of 4000.

This method is a coroutine.

_put_repr_parts_into()

Helper method to extend repr_parts with type specific fields.

__getattr__()

Drops a rich attribute error.

__repr__()

Returns the gateway's representation.