Class

VoiceManager

Manages voice connections. Use `getVoiceManager(client)` to obtain an instance.

Extends EventEmitter

Constructor

new VoiceManager(client: Client, options: VoiceManagerOptions)
ParamTypeDescription
clientClient
optionsVoiceManagerOptions

Properties

client: Client (readonly)
connectionIds: Map<string, string> (readonly)

channel_id -> connection_id (from VoiceServerUpdate; required for voice state updates)

connections: Collection<string, VoiceConnection | LiveKitRtcConnection> (readonly)

channel_id -> connection (Fluxer multi-channel: allows multiple connections per guild)

pending: Map<string, { channel: VoiceChannel; resolve: (c: VoiceConnection | LiveKitRtcConnection) => void; reject: (e: Error) => void; server?: GatewayVoiceServerUpdateDispatchData | undefined; state?: GatewayVoiceStateUpdateDispatchData | undefined; }> (readonly)

channel_id -> pending join

shardId: number (readonly)
voiceStates: VoiceStateMap (readonly)

guild_id -> user_id -> channel_id

Methods

getConnection(channelOrGuildId: string): VoiceConnection | LiveKitRtcConnection | undefined

Get the active voice connection for a channel or guild.

ParamTypeDescription
channelOrGuildIdstring

Channel ID (primary) or guild ID (returns first connection in that guild)

getVoiceChannelId(guildId: string, userId: string): string | null

Get the voice channel ID the user is currently in, or null if not in voice.

ParamTypeDescription
guildIdstring

Guild ID to look up

userIdstring

User ID to look up

handleVoiceServerUpdate(data: GatewayVoiceServerUpdateDispatchData): void
ParamTypeDescription
dataGatewayVoiceServerUpdateDispatchData
handleVoiceStatesSync(data: { guildId: string; voiceStates: Array<{ user_id: string; channel_id: string | null; }>; }): void
ParamTypeDescription
data{ guildId: string; voiceStates: Array<{ user_id: string; channel_id: string | null; }>; }
handleVoiceStateUpdate(data: GatewayVoiceStateUpdateDispatchData): void
ParamTypeDescription
dataGatewayVoiceStateUpdateDispatchData

Join a voice channel. Resolves when the connection is ready. Supports multiple connections per guild (Fluxer multi-channel).

ParamTypeDescription
channelVoiceChannel

The voice channel to join

leave(guildId: string): void

Leave all voice channels in a guild. With multi-channel support, disconnects from every channel in the guild.

ParamTypeDescription
guildIdstring

Guild ID to leave

leaveChannel(channelId: string): void

Leave a specific voice channel by channel ID.

ParamTypeDescription
channelIdstring

Channel ID to leave

listParticipantsInChannel(guildId: string, channelId: string): string[]

List participant user IDs currently in a specific voice channel.

ParamTypeDescription
guildIdstring
channelIdstring
registerConnection(channelId: string, conn: VoiceConnection | LiveKitRtcConnection): void
ParamTypeDescription
channelIdstring
connVoiceConnection | LiveKitRtcConnection
storeConnectionId(channelId: string, connectionId: string | null | undefined): void
ParamTypeDescription
channelIdstring
connectionIdstring | null | undefined
subscribeChannelParticipants(channelId: string, opts?: { autoResubscribe?: boolean; }): LiveKitReceiveSubscription[]

Subscribe to inbound audio for all known participants currently in a voice channel. Only supported for LiveKit connections.

ParamTypeDescription
channelIdstring
opts?{ autoResubscribe?: boolean; }
tryCompletePending(channelId: string, pending: { channel: VoiceChannel; resolve: (c: VoiceConnection | LiveKitRtcConnection) => void; reject: (e: Error) => void; server?: GatewayVoiceServerUpdateDispatchData; state?: GatewayVoiceStateUpdateDispatchData; }): void
ParamTypeDescription
channelIdstring
pending{ channel: VoiceChannel; resolve: (c: VoiceConnection | LiveKitRtcConnection) => void; reject: (e: Error) => void; server?: GatewayVoiceServerUpdateDispatchData; state?: GatewayVoiceStateUpdateDispatchData; }
updateVoiceState(channelId: string, partial: { self_stream?: boolean; self_video?: boolean; self_mute?: boolean; self_deaf?: boolean; }): void

Update voice state (e.g. self_stream, self_video) while in a channel. Sends a VoiceStateUpdate to the gateway so the server and clients see the change. Requires connection_id (from VoiceServerUpdate); without it, the gateway would treat the update as a new join and trigger a new VoiceServerUpdate, causing connection loops.

ParamTypeDescription
channelIdstring

Channel ID (connection key)

partial{ self_stream?: boolean; self_video?: boolean; self_mute?: boolean; self_deaf?: boolean; }

Partial voice state to update (self_stream, self_video, self_mute, self_deaf)

uploadStreamPreview(channelId: string, conn: VoiceConnection | LiveKitRtcConnection): Promise<void>

Upload a placeholder stream preview so the preview URL returns 200 instead of 404.

ParamTypeDescription
channelIdstring
connVoiceConnection | LiveKitRtcConnection