hikari.api.voice
#
Interfaces used to describe voice client implementations.
VoiceComponent #
Bases: ABC
Interface for a voice system implementation.
connections abstractmethod
property
#
connections: Mapping[Snowflake, VoiceConnection]
Return a mapping of guild-id to active voice connection.
close abstractmethod
async
#
close() -> None
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 hikari.api.VoiceComponent.disconnect
instead.
connect_to abstractmethod
async
#
connect_to(guild: SnowflakeishOr[Guild], channel: SnowflakeishOr[GuildVoiceChannel], voice_connection_type: type[_VoiceConnectionT], *, deaf: bool = False, mute: bool = False, timeout: Optional[int] = 5, **kwargs: Any) -> _VoiceConnectionT
Connect to a given voice channel.
PARAMETER | DESCRIPTION |
---|---|
guild | The guild to connect to. TYPE: |
channel | The channel or channel ID to connect to. TYPE: |
voice_connection_type | The type of voice connection to use. This should be initialized internally using the TYPE: |
deaf | If TYPE: |
mute | If TYPE: |
timeout | |
**kwargs | Any arguments to provide to the TYPE: |
RETURNS | DESCRIPTION |
---|---|
VoiceConnection | A voice connection implementation of some sort. |
disconnect abstractmethod
async
#
disconnect(guild: SnowflakeishOr[PartialGuild]) -> None
Disconnect from a given guild.
PARAMETER | DESCRIPTION |
---|---|
guild | The guild to disconnect from. TYPE: |
disconnect_all abstractmethod
async
#
disconnect_all() -> None
Disconnect all the active voice connections.
VoiceConnection #
Bases: 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.
channel_id abstractmethod
property
#
channel_id: Snowflake
ID of the voice channel this voice connection is in.
owner abstractmethod
property
#
owner: VoiceComponent
Return the component that is managing this connection.
initialize abstractmethod
async
classmethod
#
initialize(channel_id: Snowflake, endpoint: str, guild_id: Snowflake, on_close: Callable[[Self], Awaitable[None]], owner: VoiceComponent, session_id: str, shard_id: int, token: str, user_id: Snowflake, **kwargs: Any) -> Self
Initialize and connect the voice connection.
PARAMETER | DESCRIPTION |
---|---|
channel_id | The channel ID that the voice connection is actively connected to. TYPE: |
endpoint | 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). TYPE: |
guild_id | The guild ID that the websocket should connect to. TYPE: |
on_close | A shutdown hook to invoke when closing a connection to ensure the connection is unregistered from the voice component safely. |
owner | The component that made this connection object. TYPE: |
session_id | The voice session ID to use. TYPE: |
shard_id | The associated shard ID that the voice connection was generated from. TYPE: |
token | The voice token to use. TYPE: |
user_id | The user ID of the account that just joined the voice channel. TYPE: |
**kwargs | Any implementation-specific arguments to provide to the voice connection that is being initialized. TYPE: |
RETURNS | DESCRIPTION |
---|---|
VoiceConnection | The type of this connection object. |
notify abstractmethod
async
#
notify(event: VoiceEvent) -> None
Submit an event to the voice connection to be processed.