Skip to content

Queue

Represents a queue.

new Queue(
distube,
voice,
textChannel?
): Queue;

Create a queue for the guild

DisTube

DisTube

DisTubeVoice

Voice connection

GuildTextBasedChannel

Default text channel

Queue

DisTubeBase.constructor

autoplay: boolean;

Whether or not the autoplay mode is enabled. Default value: false


distube: DisTube;

The DisTube instance this object belongs to.

DisTubeBase.distube


ffmpegArgs: FFmpegArgs;

FFmpeg arguments for the current queue. Default value is defined with DisTubeOptions.ffmpeg.args. af output argument will be replaced with Queue#filters manager


readonly id: string;

Queue id (Guild id)


paused: boolean;

Whether or not the stream is currently paused.

It is also true once the queue has been stopped, so that !queue.paused stays false as soon as the queue is not playing anymore.


previousSongs: Song<unknown>[];

List of the previous songs.


repeatMode: RepeatMode;

Type of repeat mode (0 is disabled, 1 is repeating a song, 2 is repeating all the queue). Default value: 0 (disabled)


songs: Song<unknown>[];

List of songs in the queue (The first one is the playing song)


stopped: boolean;

Whether stream is currently stopped.


textChannel?: GuildTextBasedChannel;

The text channel of the Queue. (Default: where the first command is called).


voice: DisTubeVoice;

Voice connection of this queue.

get client(): Client;

Discord.js client

Client

DisTubeBase.client


get clientMember(): GuildMember | undefined;

The client user as a GuildMember of this queue’s guild

GuildMember | undefined


get crossfade(): number;

The crossfade duration (in seconds) between this song and the next one.

0 (the default) disables the crossfade. Changing it takes effect for the next transition; call Queue#scheduleCrossfade to re-arm the transition for the currently playing song immediately.

DisTubeError When the value is not a number between 0 and the maximum crossfade duration

number

set crossfade(value): void;

number

void


get currentTime(): number;

What time in the song is playing (in seconds).

number


get duration(): number;

Queue’s duration.

number


get filters(): FilterManager;

The filter manager of the queue

FilterManager


get formattedCurrentTime(): string;

Formatted Queue#currentTime string.

string


get formattedDuration(): string;

Formatted duration string.

string


get handler(): DisTubeHandler;

DisTube handler

DisTubeHandler

DisTubeBase.handler


get isActive(): boolean;

Whether or not the queue is still active.

It is false only when the queue has been stopped. A paused queue is still active.

boolean


get options(): Options;

DisTube options

Options

DisTubeBase.options


get plugins(): DisTubePlugin[];

DisTube plugins

DisTubePlugin[]

DisTubeBase.plugins


get queues(): QueueManager;

The queue manager

QueueManager

DisTubeBase.queues


get voiceChannel(): VoiceBasedChannel | null;

The voice channel playing in.

VoiceBasedChannel | null


get voices(): DisTubeVoiceManager;

The voice manager

DisTubeVoiceManager

DisTubeBase.voices


get volume(): number;

Get or set the stream volume. Default value: 50.

number

set volume(value): void;

Set the stream volume.

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

number

The volume percentage, from 0 to 100

void

addRelatedSong(song?): Promise<Song<unknown>>;

Add a related song of the playing song to the queue

Song<unknown>

The song to get related songs from. Defaults to the current playing song.

Promise<Song<unknown>>

The added song

DisTubeError When the queue does not have any playing song, or when no related song could be found


addToQueue(song, position?): Queue;

Add a song or a list of songs to the queue.

| Song<unknown> | Song<unknown>[]

Song to add

number = 0

Position to add, <= 0 to add to the end of the queue

Queue

The guild queue

queue.addToQueue(song);

debug(message): void;

Emit debug event

string

debug message

void

Nothing

DisTubeBase.debug


emit(eventName, ...args): boolean;

Emit the DisTube of this base

keyof DisTubeEvents

Event name

…any

arguments

boolean

true when the event had listeners, false otherwise

DisTubeBase.emit


emitError(
error,
queue,
song?
): void;

Emit error event

Error

error

Queue

The queue encountered the error

Song<unknown>

The playing song when encountered the error

void

Nothing

DisTubeBase.emitError


jump(position, options?): Promise<Song<unknown>>;

Jump to the song position in the queue. The next one is 1, 2,… The previous one is -1, -2,… if num is invalid number

number

The song position to play

JumpOptions

Skip options

Promise<Song<unknown>>

The new Song will be played

DisTubeError When the position is invalid, when there is no up next song, or when DisTubeOptions.savePreviousSongs is disabled and the jump is backwards


pause(): Promise<Queue>;

/**

  • Pause the guild stream

Promise<Queue>

The guild queue *

DisTubeError When the queue is already paused *

  • await queue.pause();

play(emitPlaySong?): Promise<void>;

Play the first song in the queue

boolean = true

Whether or not emit Events.PLAY_SONG event

Promise<void>

A promise that resolves when the song is playing

DisTubeError When the queue has been stopped


previous(): Promise<Song<unknown>>;

Play the previous song if exists

Promise<Song<unknown>>

The guild queue

DisTubeError When DisTubeOptions.savePreviousSongs is disabled, or when the queue does not have any previous song


remove(): void;

Remove the queue from the manager

void

Nothing


resume(): Promise<Queue>;

Resume the guild stream

Promise<Queue>

The guild queue

DisTubeError When the queue is not paused

await queue.resume();

scheduleCrossfade(): void;

Re-arm the crossfade into the next song for the currently playing one.

Useful after changing Queue#crossfade while a song is playing: the fade may still fit into the remaining time. This is called automatically after every song switch.

void

Nothing


seek(time): Promise<Queue>;

Set the playing time to another position

number

Time in seconds

Promise<Queue>

The guild queue

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

await queue.seek(60);

setRepeatMode(mode?): RepeatMode;

Set the repeat mode of the guild queue. Toggle mode (Disabled -> Song -> Queue -> Disabled ->...) if mode is undefined

RepeatMode

The repeat modes (toggle if undefined)

RepeatMode

The new repeat mode

DisTubeError When the mode is not a valid RepeatMode


setVolume(percent): Queue;

Set the guild stream’s volume

number

The percentage of volume you want to set

Queue

The guild queue

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


shuffle(): Promise<Queue>;

Shuffle the queue’s songs

Promise<Queue>

The guild queue


skip(options?): Promise<Song<unknown>>;

Skip the playing song if there is a next song in the queue. If Queue#autoplay is true and there is no up next song, DisTube will add and play a related song.

JumpOptions

Skip options

Promise<Song<unknown>>

The song will skip to

DisTubeError When there is no up next song, or when the position is out of the bounds of the queue

await queue.skip();

stop(): Promise<void>;

Stop the guild stream and delete the queue

Promise<void>

A promise that resolves when the queue is stopped


toggleAutoplay(): boolean;

Toggle autoplay mode

boolean

Autoplay mode state