.connect(server, state)
server: GatewayVoiceServerUpdateDispatchData, state: GatewayVoiceStateUpdateDispatchData → Promise<void>
Called when we have both server update and state update.
await voiceConnection.connect(server, state);Class
Voice connection using Fluxer's UDP-based protocol. Emits ready, error, disconnect.
Extends EventEmitter
new VoiceConnection(client: Client, channel: VoiceChannel, userId: string)ClientVoiceChannelstringserver: GatewayVoiceServerUpdateDispatchData, state: GatewayVoiceStateUpdateDispatchData → Promise<void>
Called when we have both server update and state update.
await voiceConnection.connect(server, state);→ void
Disconnect and remove all listeners.
voiceConnection.destroy();→ void
Disconnect from voice (closes WebSocket and UDP).
voiceConnection.disconnect();urlOrStream: string | NodeJS.ReadableStream → Promise<void>
Play a direct WebM/Opus source. When urlOrStream is a string:
http:// / https:// — fetched over the networkfile:// — read from the local filesystem./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);stream: NodeJS.ReadableStream → void
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);→ void
Stop playback and clear the queue.
voiceConnection.stop();