Interfaces used to describe voice client implementations.

Module Contents#

class hikari.api.voice.VoiceComponent[source]#

Bases: abc.ABC

Interface for a voice system implementation.

abstract property connections: Mapping[hikari.snowflakes.Snowflake, VoiceConnection][source]#

Return a mapping of guild-id to active voice connection.

abstract property is_alive: bool[source]#

Whether this component is alive.

abstract async close()[source]#

Shut down all connections, waiting for them to terminate.

Once this is done, unsubscribe from any events.

If you simply wish to disconnect every connection, use disconnect instead.

abstract async connect_to(guild, channel, voice_connection_type, *, deaf=False, mute=False, timeout=5, **kwargs)[source]#

Connect to a given voice channel.


The guild to connect to.


The channel or channel ID to connect to.


The type of voice connection to use. This should be initialized internally using the VoiceConnection.initialize classmethod.


Defaulting to False, if True, the client will enter the voice channel deafened (thus unable to hear other users).


Defaulting to False, if True, the client will enter the voice channel muted (thus unable to send audio).


Defaulting to 5, The amount of time to wait before erroring when connecting to the voice channel. If timeout is None there will be no timeout.


If timeout is None, this function will be awaited forever if an invalid guild_id or channel_id is provided.


Any arguments to provide to the VoiceConnection.initialize method.


A voice connection implementation of some sort.

abstract async disconnect(guild)[source]#

Disconnect from a given guild.


The guild to disconnect from.

abstract async disconnect_all()[source]#

Disconnect all the active voice connections.

class hikari.api.voice.VoiceConnection[source]#

Bases: abc.ABC

An abstract interface for defining how bots can interact with voice.

Since voice will generally be run in a subprocess to prevent interfering with the bot when performing CPU-bound encoding/encryption, any implementation of this is expected to implement the appropriate mechanisms for communicating with a voice subprocess and controlling it, however, this is left to the discretion of each implementation.

Control is left to the implementation to define how to perform it. The idea is to allow various decoders to be implemented to allow this to direct interface with other types of system outside this library, such as LavaLink, for example.

abstract property channel_id: hikari.snowflakes.Snowflake[source]#

ID of the voice channel this voice connection is in.

abstract property guild_id: hikari.snowflakes.Snowflake[source]#

ID of the guild this voice connection is in.

abstract property is_alive: bool[source]#

Whether the connection is alive.

abstract property owner: VoiceComponent[source]#

Return the component that is managing this connection.

abstract property shard_id: int[source]#

ID of the shard that requested the connection.

abstract async disconnect()[source]#

Signal the process to shut down.

abstract async classmethod initialize(channel_id, endpoint, guild_id, on_close, owner, session_id, shard_id, token, user_id, **kwargs)[source]#

Initialize and connect the voice connection.


The channel ID that the voice connection is actively connected to.


The voice websocket endpoint to connect to. Will contain the protocol at the start (i.e. wss://), and end with the correct port (the port and protocol are sanitized since Discord still provide the wrong information four years later).


The guild ID that the websocket should connect to.

on_closetyping.Callable[[T], typing.Awaitable[None]]

A shutdown hook to invoke when closing a connection to ensure the connection is unregistered from the voice component safely.


The component that made this connection object.


The voice session ID to use.


The associated shard ID that the voice connection was generated from.


The voice token to use.


The user ID of the account that just joined the voice channel.


Any implementation-specific arguments to provide to the voice connection that is being initialized.


The type of this connection object.

abstract async join()[source]#

Wait for the process to halt before continuing.

abstract async notify(event)[source]#

Submit an event to the voice connection to be processed.