DisTubeVoice
Create a voice connection to the voice channel
Extends
Section titled “Extends”TypedEmitter<DisTubeVoiceEvents>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DisTubeVoice(voiceManager, channel): DisTubeVoice;Create a voice connection to the voice channel.
Parameters
Section titled “Parameters”voiceManager
Section titled “voiceManager”The voice manager of the DisTube instance
channel
Section titled “channel”VoiceBasedChannel
The voice channel to join
Returns
Section titled “Returns”DisTubeVoice
Overrides
Section titled “Overrides”TypedEmitter<DisTubeVoiceEvents>.constructor
Properties
Section titled “Properties”audioPlayer
Section titled “audioPlayer”readonly audioPlayer: AudioPlayer;The audio player that plays the audio of this connection.
connection
Section titled “connection”connection: VoiceConnection;The Discord.js voice connection.
emittedError
Section titled “emittedError”emittedError: boolean;Whether or not an error was already emitted for the current stream.
It prevents the same error from being emitted several times.
readonly id: string;The id of the guild of this voice connection.
isDisconnected
Section titled “isDisconnected”isDisconnected: boolean = false;Whether or not the voice connection has been disconnected.
pausingStream?
Section titled “pausingStream?”pausingStream?: DisTubeStream;The stream that was playing when the playback was paused.
stream?
Section titled “stream?”stream?: DisTubeStream;The stream that is currently playing.
voices
Section titled “voices”readonly voices: DisTubeVoiceManager;The voice manager that instantiated this connection.
defaultMaxListeners
Section titled “defaultMaxListeners”static defaultMaxListeners: number;Inherited from
Section titled “Inherited from”TypedEmitter.defaultMaxListeners
Accessors
Section titled “Accessors”channel
Section titled “channel”Get Signature
Section titled “Get Signature”get channel(): VoiceBasedChannel;The voice channel the bot is in.
Setting it moves the bot to another voice channel.
Returns
Section titled “Returns”VoiceBasedChannel
Set Signature
Section titled “Set Signature”set channel(channel): void;Move the bot to another voice channel.
Throws
Section titled “Throws”DisTubeError When the channel is invalid, when it belongs to another guild or client, or when the bot cannot join it
Parameters
Section titled “Parameters”channel
Section titled “channel”VoiceBasedChannel
The voice channel to join
Returns
Section titled “Returns”void
channelId
Section titled “channelId”Get Signature
Section titled “Get Signature”get channelId(): string | undefined;The voice channel id the bot is in
Returns
Section titled “Returns”string | undefined
playbackDuration
Section titled “playbackDuration”Get Signature
Section titled “Get Signature”get playbackDuration(): number;Playback duration of the audio resource in seconds (time since playback started)
Returns
Section titled “Returns”number
playbackTime
Section titled “playbackTime”Get Signature
Section titled “Get Signature”get playbackTime(): number;Current playback time in seconds, accounting for seek offset
Returns
Section titled “Returns”number
selfDeaf
Section titled “selfDeaf”Get Signature
Section titled “Get Signature”get selfDeaf(): boolean;Whether the bot is self-deafened
Returns
Section titled “Returns”boolean
selfMute
Section titled “selfMute”Get Signature
Section titled “Get Signature”get selfMute(): boolean;Whether the bot is self-muted
Returns
Section titled “Returns”boolean
voiceState
Section titled “voiceState”Get Signature
Section titled “Get Signature”get voiceState(): VoiceState | undefined;The voice state of this connection
Returns
Section titled “Returns”VoiceState | undefined
volume
Section titled “volume”Get Signature
Section titled “Get Signature”get volume(): number;Get or set the volume percentage
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set volume(volume): void;Set the volume percentage of the stream.
Throws
Section titled “Throws”DisTubeError When the volume is not a number, or when it is negative
Parameters
Section titled “Parameters”volume
Section titled “volume”number
The volume percentage, from 0 to 100
Returns
Section titled “Returns”void
Methods
Section titled “Methods”addListener()
Section titled “addListener()”addListener<U>(event, listener): this;Type Parameters
Section titled “Type Parameters”U extends keyof DisTubeVoiceEvents
Parameters
Section titled “Parameters”U
listener
Section titled “listener”Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”TypedEmitter.addListener
emit()
Section titled “emit()”emit<U>(event, ...args): boolean;Emit an event of the voice connection.
The special "error" event never crashes the process when there is no
listener for it, even when the voice connection is used outside of a
Queue.
Type Parameters
Section titled “Type Parameters”U extends keyof DisTubeVoiceEvents
Parameters
Section titled “Parameters”U
The event name
…Parameters<DisTubeVoiceEvents[U]>
The event arguments
Returns
Section titled “Returns”boolean
true when the event had listeners, false otherwise
Overrides
Section titled “Overrides”TypedEmitter.emit
eventNames()
Section titled “eventNames()”eventNames<U>(): U[];Type Parameters
Section titled “Type Parameters”U extends keyof DisTubeVoiceEvents
Returns
Section titled “Returns”U[]
Inherited from
Section titled “Inherited from”TypedEmitter.eventNames
getMaxListeners()
Section titled “getMaxListeners()”getMaxListeners(): number;Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”TypedEmitter.getMaxListeners
join()
Section titled “join()”join(channel?): Promise<DisTubeVoice>;Join a voice channel with this connection
Parameters
Section titled “Parameters”channel?
Section titled “channel?”VoiceBasedChannel
A voice channel
Returns
Section titled “Returns”Promise<DisTubeVoice>
The voice connection
Throws
Section titled “Throws”DisTubeError When the connection cannot be established
leave()
Section titled “leave()”leave(error?): void;Leave the voice channel of this connection
Parameters
Section titled “Parameters”error?
Section titled “error?”Error
Optional, an error to emit with ‘error’ event.
Returns
Section titled “Returns”void
Nothing
listenerCount()
Section titled “listenerCount()”listenerCount(type): number;Parameters
Section titled “Parameters”keyof DisTubeVoiceEvents
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”TypedEmitter.listenerCount
listeners()
Section titled “listeners()”listeners<U>(type): DisTubeVoiceEvents[U][];Type Parameters
Section titled “Type Parameters”U extends keyof DisTubeVoiceEvents
Parameters
Section titled “Parameters”U
Returns
Section titled “Returns”DisTubeVoiceEvents[U][]
Inherited from
Section titled “Inherited from”TypedEmitter.listeners
off<U>(event, listener): this;Type Parameters
Section titled “Type Parameters”U extends keyof DisTubeVoiceEvents
Parameters
Section titled “Parameters”U
listener
Section titled “listener”Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”TypedEmitter.off
on<U>(event, listener): this;Type Parameters
Section titled “Type Parameters”U extends keyof DisTubeVoiceEvents
Parameters
Section titled “Parameters”U
listener
Section titled “listener”Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”TypedEmitter.on
once()
Section titled “once()”once<U>(event, listener): this;Type Parameters
Section titled “Type Parameters”U extends keyof DisTubeVoiceEvents
Parameters
Section titled “Parameters”U
listener
Section titled “listener”Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”TypedEmitter.once
pause()
Section titled “pause()”pause(): void;Pause the playback of the audio player.
Returns
Section titled “Returns”void
Nothing
play()
Section titled “play()”play(dtStream): Promise<void>;Play a DisTubeStream
Parameters
Section titled “Parameters”dtStream
Section titled “dtStream”DisTubeStream
Returns
Section titled “Returns”Promise<void>
A promise that resolves when the stream is playing
Throws
Section titled “Throws”DisTubeError When no encryption library is available
prependListener()
Section titled “prependListener()”prependListener<U>(event, listener): this;Type Parameters
Section titled “Type Parameters”U extends keyof DisTubeVoiceEvents
Parameters
Section titled “Parameters”U
listener
Section titled “listener”Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”TypedEmitter.prependListener
prependOnceListener()
Section titled “prependOnceListener()”prependOnceListener<U>(event, listener): this;Type Parameters
Section titled “Type Parameters”U extends keyof DisTubeVoiceEvents
Parameters
Section titled “Parameters”U
listener
Section titled “listener”Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”TypedEmitter.prependOnceListener
rawListeners()
Section titled “rawListeners()”rawListeners<U>(type): DisTubeVoiceEvents[U][];Type Parameters
Section titled “Type Parameters”U extends keyof DisTubeVoiceEvents
Parameters
Section titled “Parameters”U
Returns
Section titled “Returns”DisTubeVoiceEvents[U][]
Inherited from
Section titled “Inherited from”TypedEmitter.rawListeners
removeAllListeners()
Section titled “removeAllListeners()”removeAllListeners(event?): this;Parameters
Section titled “Parameters”event?
Section titled “event?”keyof DisTubeVoiceEvents
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”TypedEmitter.removeAllListeners
removeListener()
Section titled “removeListener()”removeListener<U>(event, listener): this;Type Parameters
Section titled “Type Parameters”U extends keyof DisTubeVoiceEvents
Parameters
Section titled “Parameters”U
listener
Section titled “listener”Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”TypedEmitter.removeListener
setMaxListeners()
Section titled “setMaxListeners()”setMaxListeners(n): this;Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”TypedEmitter.setMaxListeners
setSelfDeaf()
Section titled “setSelfDeaf()”setSelfDeaf(selfDeaf): boolean;Self-deafens/undeafens the bot.
Parameters
Section titled “Parameters”selfDeaf
Section titled “selfDeaf”boolean
Whether or not the bot should be self-deafened
Returns
Section titled “Returns”boolean
true if the voice state was successfully updated, otherwise false
Throws
Section titled “Throws”DisTubeError When the value is not a boolean
setSelfMute()
Section titled “setSelfMute()”setSelfMute(selfMute): boolean;Self-mutes/unmutes the bot.
Parameters
Section titled “Parameters”selfMute
Section titled “selfMute”boolean
Whether or not the bot should be self-muted
Returns
Section titled “Returns”boolean
true if the voice state was successfully updated, otherwise false
Throws
Section titled “Throws”DisTubeError When the value is not a boolean
stop()
Section titled “stop()”stop(force?): void;Stop the playing stream
Parameters
Section titled “Parameters”force?
Section titled “force?”boolean = false
If true, will force the DisTubeVoice#audioPlayer to enter the Idle state even if the DisTubeStream#audioResource has silence padding frames.
Returns
Section titled “Returns”void
Nothing
unpause()
Section titled “unpause()”unpause(): void;Resume the playback of the audio player.
The FFmpeg process is spawned again when the stream was killed while the playback was paused.
Returns
Section titled “Returns”void
Nothing