Skip to content

DisTubeVoice

Create a voice connection to the voice channel

new DisTubeVoice(voiceManager, channel): DisTubeVoice;

Create a voice connection to the voice channel.

DisTubeVoiceManager

The voice manager of the DisTube instance

VoiceBasedChannel

The voice channel to join

DisTubeVoice

TypedEmitter<DisTubeVoiceEvents>.constructor

readonly audioPlayer: AudioPlayer;

The audio player that plays the audio of this connection.


connection: VoiceConnection;

The Discord.js voice connection.


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: boolean = false;

Whether or not the voice connection has been disconnected.


pausingStream?: DisTubeStream;

The stream that was playing when the playback was paused.


stream?: DisTubeStream;

The stream that is currently playing.


readonly voices: DisTubeVoiceManager;

The voice manager that instantiated this connection.


static defaultMaxListeners: number;

TypedEmitter.defaultMaxListeners

get channel(): VoiceBasedChannel;

The voice channel the bot is in.

Setting it moves the bot to another voice channel.

VoiceBasedChannel

set channel(channel): void;

Move the bot to another voice channel.

DisTubeError When the channel is invalid, when it belongs to another guild or client, or when the bot cannot join it

VoiceBasedChannel

The voice channel to join

void


get channelId(): string | undefined;

The voice channel id the bot is in

string | undefined


get playbackDuration(): number;

Playback duration of the audio resource in seconds (time since playback started)

number


get playbackTime(): number;

Current playback time in seconds, accounting for seek offset

number


get selfDeaf(): boolean;

Whether the bot is self-deafened

boolean


get selfMute(): boolean;

Whether the bot is self-muted

boolean


get voiceState(): VoiceState | undefined;

The voice state of this connection

VoiceState | undefined


get volume(): number;

Get or set the volume percentage

number

set volume(volume): void;

Set the volume percentage of the stream.

DisTubeError When the volume is not a number, or when it is negative

number

The volume percentage, from 0 to 100

void

addListener<U>(event, listener): this;

U extends keyof DisTubeVoiceEvents

U

DisTubeVoiceEvents[U]

this

TypedEmitter.addListener


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.

U extends keyof DisTubeVoiceEvents

U

The event name

…Parameters<DisTubeVoiceEvents[U]>

The event arguments

boolean

true when the event had listeners, false otherwise

TypedEmitter.emit


eventNames<U>(): U[];

U extends keyof DisTubeVoiceEvents

U[]

TypedEmitter.eventNames


getMaxListeners(): number;

number

TypedEmitter.getMaxListeners


join(channel?): Promise<DisTubeVoice>;

Join a voice channel with this connection

VoiceBasedChannel

A voice channel

Promise<DisTubeVoice>

The voice connection

DisTubeError When the connection cannot be established


leave(error?): void;

Leave the voice channel of this connection

Error

Optional, an error to emit with ‘error’ event.

void

Nothing


listenerCount(type): number;

keyof DisTubeVoiceEvents

number

TypedEmitter.listenerCount


listeners<U>(type): DisTubeVoiceEvents[U][];

U extends keyof DisTubeVoiceEvents

U

DisTubeVoiceEvents[U][]

TypedEmitter.listeners


off<U>(event, listener): this;

U extends keyof DisTubeVoiceEvents

U

DisTubeVoiceEvents[U]

this

TypedEmitter.off


on<U>(event, listener): this;

U extends keyof DisTubeVoiceEvents

U

DisTubeVoiceEvents[U]

this

TypedEmitter.on


once<U>(event, listener): this;

U extends keyof DisTubeVoiceEvents

U

DisTubeVoiceEvents[U]

this

TypedEmitter.once


pause(): void;

Pause the playback of the audio player.

void

Nothing


play(dtStream): Promise<void>;

Play a DisTubeStream

DisTubeStream

DisTubeStream

Promise<void>

A promise that resolves when the stream is playing

DisTubeError When no encryption library is available


prependListener<U>(event, listener): this;

U extends keyof DisTubeVoiceEvents

U

DisTubeVoiceEvents[U]

this

TypedEmitter.prependListener


prependOnceListener<U>(event, listener): this;

U extends keyof DisTubeVoiceEvents

U

DisTubeVoiceEvents[U]

this

TypedEmitter.prependOnceListener


rawListeners<U>(type): DisTubeVoiceEvents[U][];

U extends keyof DisTubeVoiceEvents

U

DisTubeVoiceEvents[U][]

TypedEmitter.rawListeners


removeAllListeners(event?): this;

keyof DisTubeVoiceEvents

this

TypedEmitter.removeAllListeners


removeListener<U>(event, listener): this;

U extends keyof DisTubeVoiceEvents

U

DisTubeVoiceEvents[U]

this

TypedEmitter.removeListener


setMaxListeners(n): this;

number

this

TypedEmitter.setMaxListeners


setSelfDeaf(selfDeaf): boolean;

Self-deafens/undeafens the bot.

boolean

Whether or not the bot should be self-deafened

boolean

true if the voice state was successfully updated, otherwise false

DisTubeError When the value is not a boolean


setSelfMute(selfMute): boolean;

Self-mutes/unmutes the bot.

boolean

Whether or not the bot should be self-muted

boolean

true if the voice state was successfully updated, otherwise false

DisTubeError When the value is not a boolean


stop(force?): void;

Stop the playing stream

boolean = false

If true, will force the DisTubeVoice#audioPlayer to enter the Idle state even if the DisTubeStream#audioResource has silence padding frames.

void

Nothing


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.

void

Nothing