VoiceConnection
Voice connection using Discord's UDP-based protocol. Emits `ready`, `error`, `disconnect`.
Extends EventEmitter
Constructor
(client: Client, channel: VoiceChannel, userId: string)| Param | Type | Description |
|---|---|---|
| client | Client | |
| channel | VoiceChannel | |
| userId | string |
Properties
: Buffer[]: VoiceChannel (readonly): Client (readonly): { destroy?: () => void } | null: string (readonly): ReturnType<typeof setInterval> | null: ReturnType<typeof setInterval> | null: boolean (readonly)Whether audio is currently playing.
: string: number: Uint8Array | null: number: string | null (readonly)Discord voice session ID.
: number: number: dgram.Socket | null: VoiceWebSocket | nullMethods
(server: GatewayVoiceServerUpdateDispatchData, state: GatewayVoiceStateUpdateDispatchData): Promise<void>Called when we have both server update and state update.
| Param | Type | Description |
|---|---|---|
| server | GatewayVoiceServerUpdateDispatchData | |
| state | GatewayVoiceStateUpdateDispatchData |
(): voidDisconnect and remove all listeners.
(): voidDisconnect from voice (closes WebSocket and UDP).
(): Promise<new (url: string) => VoiceWebSocket>(urlOrStream: string | NodeJS.ReadableStream): Promise<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.
| Param | Type | Description |
|---|---|---|
| urlOrStream | string | NodeJS.ReadableStream |
(stream: NodeJS.ReadableStream): voidPlay 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.
| Param | Type | Description |
|---|---|---|
| stream | NodeJS.ReadableStream |
(opusPayload: Buffer): void| Param | Type | Description |
|---|---|---|
| opusPayload | Buffer |
(op: number, d: unknown): void| Param | Type | Description |
|---|---|---|
| op | number | |
| d | unknown |
(remoteAddress: string, remotePort: number, onReady: () => void): void| Param | Type | Description |
|---|---|---|
| remoteAddress | string | |
| remotePort | number | |
| onReady | () => void |
(): voidStop playback and clear the queue.