Class DiscordVoiceConnection
A connection to voice for a single guild.
Implements
Inherited Members
Namespace: Discore.Voice
Assembly: Discore.dll
Syntax
public sealed class DiscordVoiceConnection : IDisposable
Remarks
Only one voice connection can exist at a time per guild. Voice connections can only be connected to one voice channel at a time.
Constructors
| Name | Description |
|---|---|
| DiscordVoiceConnection(IGatewayVoiceBridge, Snowflake, Snowflake) | Creates a new voice connection for a guild. |
| DiscordVoiceConnection(Shard, Snowflake) | Creates a new voice connection for a guild managed by the given shard. |
Fields
| Name | Description |
|---|---|
| PCM_BLOCK_SIZE | The byte size of a single PCM audio block. |
Properties
| Name | Description |
|---|---|
| BytesToSend | Gets the number of unsent voice data bytes. |
| GuildId | Gets the ID of the guild this voice connection is in. |
| IsConnected | Gets whether this connection is connected. |
| IsConnecting | Gets whether this connection is currently performing its handshake. |
| IsPaused | Gets or sets whether the sending of voice data is paused. |
| IsSpeaking | Gets whether this connection is currently set to "speaking". |
| IsValid | Gets whether this connection is available to use. |
| SpeakingFlags | Gets the speaking state of this connection. |
| VoiceChannelId | Gets the ID of the current voice channel this connection is in. |
Methods
| Name | Description |
|---|---|
| CanSendVoiceData(int) | Gets whether the specified number of bytes can currently be sent to this voice connection. Will return false if not yet connected or invalid. |
| ClearVoiceBuffer() | Clears all queued voice data. Does nothing if this connection is invalid. |
| ConnectAsync(Snowflake, bool, bool, TimeSpan?, CancellationToken?) | Initiates this voice connection and connects to a voice channel. |
| DisconnectAsync(CancellationToken?) | Closes this voice connection. Note: The connection will still be closed if the passed cancellation token is cancelled. |
| Dispose() | Releases all resources used by this voice connection. Note: this will not invalidate the voice connection. |
| SendVoiceData(byte[], int, int) | Queues the specified PCM bytes to be sent over this voice connection. The size of the data should be equal to or less than PCM_BLOCK_SIZE. Should be used along-side CanSendVoiceData(int) to avoid overflowing the buffer. This call will not block and users do not need to worry about calling this at a certain rate. Does nothing if this connection is invalid. |
| SetSpeakingAsync(SpeakingFlag) | Sets the speaking state of this connection. Does nothing if this connection is invalid. |
| SetSpeakingAsync(bool) | Sets the speaking state of this connection. Does nothing if this connection is invalid. |
| UpdateVoiceStateAsync(Snowflake, bool, bool, CancellationToken?) | Moves channels and/or changes the applications self muted/deafened states. |
Events
| Name | Description |
|---|---|
| OnConnected | Called when the voice connection first connects or reconnects. |
| OnInvalidated | Called when this voice connection is no longer useable. (eg. disconnected, error, failure to connect). |
| OnMemberSpeaking | Called when another user in the voice channel this connection is connected to changes their speaking state. |