Skip to content

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.

new VoiceConnection(options): VoiceConnection

Defined in: packages/voice/src/connection.ts:151

JoinVoiceChannelOptions

VoiceConnection

Emitter<VoiceConnectionEvents>.constructor

channelId: string

Defined in: packages/voice/src/connection.ts:130


optional disconnectReason?: DisconnectReason

Defined in: packages/voice/src/connection.ts:134

Why it is disconnected, while it is.


readonly guildId: string

Defined in: packages/voice/src/connection.ts:129


readonly receiver: VoiceReceiver

Defined in: packages/voice/src/connection.ts:136

Incoming audio.


selfDeaf: boolean

Defined in: packages/voice/src/connection.ts:132


selfMute: boolean

Defined in: packages/voice/src/connection.ts:131


status: VoiceConnectionStatus = "signalling"

Defined in: packages/voice/src/connection.ts:128

get endToEndEncrypted(): boolean

Defined in: packages/voice/src/connection.ts:191

Whether audio is end-to-end encrypted (DAVE) right now.

boolean


get ping(): number

Defined in: packages/voice/src/connection.ts:181

Heartbeat round trip of the voice gateway in ms, or -1.

number


get subscription(): PlayerSubscription | undefined

Defined in: packages/voice/src/connection.ts:196

The subscribed player’s subscription, if any.

PlayerSubscription | undefined


get voicePrivacyCode(): string | null

Defined in: packages/voice/src/connection.ts:186

The voice privacy code (DAVE) users can compare, or null.

string | null

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.

boolean = true

Send op 4 to leave the channel (default true).

void


disconnect(): boolean

Defined in: packages/voice/src/connection.ts:433

Leaves the channel (op 4 with no channel); rejoin() can bring it back.

boolean

Whether op 4 was sent.


off<K>(event, listener): this

Defined in: packages/voice/src/emitter.ts:21

Removes a listener.

K extends keyof VoiceConnectionEvents

K

(…args) => unknown

this

Emitter.off


on<K>(event, listener): this

Defined in: packages/voice/src/emitter.ts:8

Adds a listener.

K extends keyof VoiceConnectionEvents

K

(…args) => unknown

this

If it is not a function.

Emitter.on


playOpusPacket(frame): boolean

Defined in: packages/voice/src/connection.ts:498

Sends one 20 ms Opus frame now (for custom audio pipelines).

Uint8Array

boolean

Whether it was sent.


rejoin(options?): boolean

Defined in: packages/voice/src/connection.ts:406

Joins again, or moves to another channel, or changes mute/deaf.

string

boolean

boolean

boolean

Whether op 4 was sent.

If destroyed.


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.

boolean

void


subscribe(player): PlayerSubscription

Defined in: packages/voice/src/connection.ts:474

Plays player on this connection, replacing any other player.

AudioPlayer

PlayerSubscription