VoiceClient
Represents a Discord voice connection. You typically get these fromVoiceChannel.connect().
Attributes
The voice connection session ID.
The voice connection token.
The endpoint we are connecting to.
The voice channel connected to.
The event loop that the voice client is running on.
The guild we’re connected to, if applicable. (property)
The user connected to voice (i.e. ourselves). (property)
Latency between a HEARTBEAT and a HEARTBEAT_ACK in seconds. (property)
Average of most recent 20 HEARTBEAT latencies in seconds. (property)
The audio source being played, if playing. Can also be set to change the source. (property)
Methods
connect
The timeout for the connection.
Whether reconnection is expected.
disconnect
Whether the disconnection was forced.
move_to
The channel to move to. Must be a voice channel.
is_connected
play
after, is called after the source has been exhausted or an error occurred.
The audio source we’re reading from.
The finalizer that is called after the stream is exhausted. This function must have a single parameter,
error, that denotes an optional exception that was raised during playing.If True, an awaitable will be returned, which can be used to wait for audio to stop playing. This awaitable will return an exception if raised, or None when no exception is raised.If False, None is returned and the function does not block.
ClientException- Already playing audio or not connected.TypeError- Source is not an AudioSource or after is not a callable.OpusNotLoaded- Source is not opus encoded and opus is not loaded.
is_playing
is_paused
stop
pause
resume
send_audio_packet
The bytes-like object denoting PCM or Opus voice data.
Indicates if
data should be encoded into Opus.ClientException- You are not connected.opus.OpusError- Encoding the data failed.
elapsed
Recording Methods
start_recording
A Sink which will “store” all the audio data.
A function which is called after the bot has stopped recording.
*args
Args which will be passed to the callback function.
If True, the recordings of subsequent users will start with silence. This is useful for recording audio just as it was heard.
RecordingException- Not connected to a voice channel.RecordingException- Already recording.RecordingException- Must provide a Sink object.
stop_recording
RecordingException- Not currently recording.
toggle_pause
RecordingException- Not currently recording audio.
VoiceProtocol
Abstract base class for voice protocol implementations. This is an abstract class. The library provides a concrete implementation underVoiceClient.
This class allows you to implement a protocol to allow for an external method of sending voice, such as Lavalink or a native library implementation.
Methods
on_voice_state_update
VOICE_STATE_UPDATE.
The raw voice state payload.
on_voice_server_update
VOICE_SERVER_UPDATE.
The raw voice server update payload.
connect
disconnect
cleanup
disconnect when you are completely done with the voice protocol instance.