VoiceConnection
Defined in: packages/voice/src/connection.ts:127
The bot’s voice session in one guild: it asks Discord to join (op 4),
connects to the voice server when the voice state and server arrive,
reconnects when the server or channel changes, and sends a subscribed
player’s audio. Create it with client.voice.join() or
joinVoiceChannel.
Extends
Section titled “Extends”Emitter<VoiceConnectionEvents>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new VoiceConnection(
options):VoiceConnection
Defined in: packages/voice/src/connection.ts:151
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”VoiceConnection
Overrides
Section titled “Overrides”Emitter<VoiceConnectionEvents>.constructor
Properties
Section titled “Properties”channelId
Section titled “channelId”channelId:
string
Defined in: packages/voice/src/connection.ts:130
disconnectReason?
Section titled “disconnectReason?”
optionaldisconnectReason?:DisconnectReason
Defined in: packages/voice/src/connection.ts:134
Why it is disconnected, while it is.
guildId
Section titled “guildId”
readonlyguildId:string
Defined in: packages/voice/src/connection.ts:129
receiver
Section titled “receiver”
readonlyreceiver:VoiceReceiver
Defined in: packages/voice/src/connection.ts:136
Incoming audio.
selfDeaf
Section titled “selfDeaf”selfDeaf:
boolean
Defined in: packages/voice/src/connection.ts:132
selfMute
Section titled “selfMute”selfMute:
boolean
Defined in: packages/voice/src/connection.ts:131
status
Section titled “status”status:
VoiceConnectionStatus="signalling"
Defined in: packages/voice/src/connection.ts:128
Accessors
Section titled “Accessors”endToEndEncrypted
Section titled “endToEndEncrypted”Get Signature
Section titled “Get Signature”get endToEndEncrypted():
boolean
Defined in: packages/voice/src/connection.ts:191
Whether audio is end-to-end encrypted (DAVE) right now.
Returns
Section titled “Returns”boolean
Get Signature
Section titled “Get Signature”get ping():
number
Defined in: packages/voice/src/connection.ts:181
Heartbeat round trip of the voice gateway in ms, or -1.
Returns
Section titled “Returns”number
subscription
Section titled “subscription”Get Signature
Section titled “Get Signature”get subscription():
PlayerSubscription|undefined
Defined in: packages/voice/src/connection.ts:196
The subscribed player’s subscription, if any.
Returns
Section titled “Returns”PlayerSubscription | undefined
voicePrivacyCode
Section titled “voicePrivacyCode”Get Signature
Section titled “Get Signature”get voicePrivacyCode():
string|null
Defined in: packages/voice/src/connection.ts:186
The voice privacy code (DAVE) users can compare, or null.
Returns
Section titled “Returns”string | null
Methods
Section titled “Methods”destroy()
Section titled “destroy()”destroy(
leave?):void
Defined in: packages/voice/src/connection.ts:450
Leaves and releases everything: voice gateway, UDP socket, DAVE state, receiver streams, timers and the player subscription.
Parameters
Section titled “Parameters”leave?
Section titled “leave?”boolean = true
Send op 4 to leave the channel (default true).
Returns
Section titled “Returns”void
disconnect()
Section titled “disconnect()”disconnect():
boolean
Defined in: packages/voice/src/connection.ts:433
Leaves the channel (op 4 with no channel); rejoin() can bring it back.
Returns
Section titled “Returns”boolean
Whether op 4 was sent.
off<
K>(event,listener):this
Defined in: packages/voice/src/emitter.ts:21
Removes a listener.
Type Parameters
Section titled “Type Parameters”K extends keyof VoiceConnectionEvents
Parameters
Section titled “Parameters”K
listener
Section titled “listener”(…args) => unknown
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”Emitter.off
on<
K>(event,listener):this
Defined in: packages/voice/src/emitter.ts:8
Adds a listener.
Type Parameters
Section titled “Type Parameters”K extends keyof VoiceConnectionEvents
Parameters
Section titled “Parameters”K
listener
Section titled “listener”(…args) => unknown
Returns
Section titled “Returns”this
Throws
Section titled “Throws”If it is not a function.
Inherited from
Section titled “Inherited from”Emitter.on
playOpusPacket()
Section titled “playOpusPacket()”playOpusPacket(
frame):boolean
Defined in: packages/voice/src/connection.ts:498
Sends one 20 ms Opus frame now (for custom audio pipelines).
Parameters
Section titled “Parameters”Uint8Array
Returns
Section titled “Returns”boolean
Whether it was sent.
rejoin()
Section titled “rejoin()”rejoin(
options?):boolean
Defined in: packages/voice/src/connection.ts:406
Joins again, or moves to another channel, or changes mute/deaf.
Parameters
Section titled “Parameters”options?
Section titled “options?”channelId?
Section titled “channelId?”string
selfDeaf?
Section titled “selfDeaf?”boolean
selfMute?
Section titled “selfMute?”boolean
Returns
Section titled “Returns”boolean
Whether op 4 was sent.
Throws
Section titled “Throws”If destroyed.
setSpeaking()
Section titled “setSpeaking()”setSpeaking(
speaking):void
Defined in: packages/voice/src/connection.ts:493
Sends op 5 now. Players do this on their own; use it for custom audio.
Parameters
Section titled “Parameters”speaking
Section titled “speaking”boolean
Returns
Section titled “Returns”void
subscribe()
Section titled “subscribe()”subscribe(
player):PlayerSubscription
Defined in: packages/voice/src/connection.ts:474
Plays player on this connection, replacing any other player.