Class

VoiceConnection

Voice connection using Fluxer's UDP-based protocol. Emits ready, error, disconnect.

Extends EventEmitter

Constructor

new VoiceConnection(client: Client, channel: VoiceChannel, userId: string)
client
Client
userId
string

Properties

NameTypeDescription
channelread-onlyVoiceChannel
clientread-onlyClient
guildIdread-onlystring
playingread-onlybooleanWhether audio is currently playing.
sessionIdread-onlystring | nullVoice session ID.

Methods

.destroy()

void

Disconnect and remove all listeners.

voiceConnection.destroy();

.disconnect()

void

Disconnect from voice (closes WebSocket and UDP).

voiceConnection.disconnect();

.play(urlOrStream)

urlOrStream: string | NodeJS.ReadableStreamPromise<void>

Play a direct WebM/Opus source. When urlOrStream is a string:

  • http:// / https:// — fetched over the network
  • file:// — read from the local filesystem
  • any other string — treated as a filesystem path (e.g. ./music/track.webm)

You can also pass a Node.js Readable stream. Demuxes with prism-media WebmDemuxer; no FFmpeg; input must be WebM with Opus.

await voiceConnection.play(urlOrStream);

.playOpus(stream)

stream: NodeJS.ReadableStreamvoid

Play a stream of raw Opus packets Uses the same queue and 20ms pacing as play(). Use this for raw Opus packet streams (e.g. MP3 → PCM → Opus pipelines) when you are not using WebM/Opus.

voiceConnection.playOpus(stream);

.stop()

void

Stop playback and clear the queue.

voiceConnection.stop();