Queue
Represents a queue.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Queue( distube, voice, textChannel?): Queue;Create a queue for the guild
Parameters
Section titled “Parameters”distube
Section titled “distube”DisTube
Voice connection
textChannel?
Section titled “textChannel?”GuildTextBasedChannel
Default text channel
Returns
Section titled “Returns”Queue
Overrides
Section titled “Overrides”Properties
Section titled “Properties”autoplay
Section titled “autoplay”autoplay: boolean;Whether or not the autoplay mode is enabled. Default value: false
distube
Section titled “distube”distube: DisTube;The DisTube instance this object belongs to.
Inherited from
Section titled “Inherited from”ffmpegArgs
Section titled “ffmpegArgs”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
Section titled “paused”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
Section titled “previousSongs”previousSongs: Song<unknown>[];List of the previous songs.
repeatMode
Section titled “repeatMode”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
Section titled “stopped”stopped: boolean;Whether stream is currently stopped.
textChannel?
Section titled “textChannel?”textChannel?: GuildTextBasedChannel;The text channel of the Queue. (Default: where the first command is called).
voice: DisTubeVoice;Voice connection of this queue.
Accessors
Section titled “Accessors”client
Section titled “client”Get Signature
Section titled “Get Signature”get client(): Client;Discord.js client
Returns
Section titled “Returns”Client
Inherited from
Section titled “Inherited from”clientMember
Section titled “clientMember”Get Signature
Section titled “Get Signature”get clientMember(): GuildMember | undefined;The client user as a GuildMember of this queue’s guild
Returns
Section titled “Returns”GuildMember | undefined
crossfade
Section titled “crossfade”Get Signature
Section titled “Get Signature”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.
Throws
Section titled “Throws”DisTubeError When the value is not a number between 0
and the maximum crossfade duration
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set crossfade(value): void;Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
currentTime
Section titled “currentTime”Get Signature
Section titled “Get Signature”get currentTime(): number;What time in the song is playing (in seconds).
Returns
Section titled “Returns”number
duration
Section titled “duration”Get Signature
Section titled “Get Signature”get duration(): number;Queue’s duration.
Returns
Section titled “Returns”number
filters
Section titled “filters”Get Signature
Section titled “Get Signature”get filters(): FilterManager;The filter manager of the queue
Returns
Section titled “Returns”formattedCurrentTime
Section titled “formattedCurrentTime”Get Signature
Section titled “Get Signature”get formattedCurrentTime(): string;Formatted Queue#currentTime string.
Returns
Section titled “Returns”string
formattedDuration
Section titled “formattedDuration”Get Signature
Section titled “Get Signature”get formattedDuration(): string;Formatted duration string.
Returns
Section titled “Returns”string
handler
Section titled “handler”Get Signature
Section titled “Get Signature”get handler(): DisTubeHandler;DisTube handler
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”isActive
Section titled “isActive”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”boolean
options
Section titled “options”Get Signature
Section titled “Get Signature”get options(): Options;DisTube options
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”plugins
Section titled “plugins”Get Signature
Section titled “Get Signature”get plugins(): DisTubePlugin[];DisTube plugins
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”queues
Section titled “queues”Get Signature
Section titled “Get Signature”get queues(): QueueManager;The queue manager
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”voiceChannel
Section titled “voiceChannel”Get Signature
Section titled “Get Signature”get voiceChannel(): VoiceBasedChannel | null;The voice channel playing in.
Returns
Section titled “Returns”VoiceBasedChannel | null
voices
Section titled “voices”Get Signature
Section titled “Get Signature”get voices(): DisTubeVoiceManager;The voice manager
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”volume
Section titled “volume”Get Signature
Section titled “Get Signature”get volume(): number;Get or set the stream volume. Default value: 50.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set volume(value): void;Set the stream volume.
Throws
Section titled “Throws”DisTubeError When the volume is not a number, or when it is negative
Parameters
Section titled “Parameters”number
The volume percentage, from 0 to 100
Returns
Section titled “Returns”void
Methods
Section titled “Methods”addRelatedSong()
Section titled “addRelatedSong()”addRelatedSong(song?): Promise<Song<unknown>>;Add a related song of the playing song to the queue
Parameters
Section titled “Parameters”Song<unknown>
The song to get related songs from. Defaults to the current playing song.
Returns
Section titled “Returns”Promise<Song<unknown>>
The added song
Throws
Section titled “Throws”DisTubeError When the queue does not have any playing song, or when no related song could be found
addToQueue()
Section titled “addToQueue()”addToQueue(song, position?): Queue;Add a song or a list of songs to the queue.
Parameters
Section titled “Parameters”| Song<unknown>
| Song<unknown>[]
Song to add
position?
Section titled “position?”number = 0
Position to add, <= 0 to add to the end of the queue
Returns
Section titled “Returns”Queue
The guild queue
Throws
Section titled “Throws”Example
Section titled “Example”queue.addToQueue(song);debug()
Section titled “debug()”debug(message): void;Emit debug event
Parameters
Section titled “Parameters”message
Section titled “message”string
debug message
Returns
Section titled “Returns”void
Nothing
Inherited from
Section titled “Inherited from”emit()
Section titled “emit()”emit(eventName, ...args): boolean;Emit the DisTube of this base
Parameters
Section titled “Parameters”eventName
Section titled “eventName”keyof DisTubeEvents
Event name
…any
arguments
Returns
Section titled “Returns”boolean
true when the event had listeners, false otherwise
Inherited from
Section titled “Inherited from”emitError()
Section titled “emitError()”emitError( error, queue, song?): void;Emit error event
Parameters
Section titled “Parameters”Error
error
Queue
The queue encountered the error
Song<unknown>
The playing song when encountered the error
Returns
Section titled “Returns”void
Nothing
Inherited from
Section titled “Inherited from”jump()
Section titled “jump()”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
Parameters
Section titled “Parameters”position
Section titled “position”number
The song position to play
options?
Section titled “options?”Skip options
Returns
Section titled “Returns”Promise<Song<unknown>>
The new Song will be played
Throws
Section titled “Throws”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()
Section titled “pause()”pause(): Promise<Queue>;/**
- Pause the guild stream
Returns
Section titled “Returns”Promise<Queue>
The guild queue *
Throws
Section titled “Throws”DisTubeError When the queue is already paused *
Example
Section titled “Example”-
- await queue.pause();
-
play()
Section titled “play()”play(emitPlaySong?): Promise<void>;Play the first song in the queue
Parameters
Section titled “Parameters”emitPlaySong?
Section titled “emitPlaySong?”boolean = true
Whether or not emit Events.PLAY_SONG event
Returns
Section titled “Returns”Promise<void>
A promise that resolves when the song is playing
Throws
Section titled “Throws”DisTubeError When the queue has been stopped
previous()
Section titled “previous()”previous(): Promise<Song<unknown>>;Play the previous song if exists
Returns
Section titled “Returns”Promise<Song<unknown>>
The guild queue
Throws
Section titled “Throws”DisTubeError When DisTubeOptions.savePreviousSongs is disabled, or when the queue does not have any previous song
remove()
Section titled “remove()”remove(): void;Remove the queue from the manager
Returns
Section titled “Returns”void
Nothing
resume()
Section titled “resume()”resume(): Promise<Queue>;Resume the guild stream
Returns
Section titled “Returns”Promise<Queue>
The guild queue
Throws
Section titled “Throws”DisTubeError When the queue is not paused
Example
Section titled “Example”await queue.resume();scheduleCrossfade()
Section titled “scheduleCrossfade()”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.
Returns
Section titled “Returns”void
Nothing
seek()
Section titled “seek()”seek(time): Promise<Queue>;Set the playing time to another position
Parameters
Section titled “Parameters”number
Time in seconds
Returns
Section titled “Returns”Promise<Queue>
The guild queue
Throws
Section titled “Throws”DisTubeError When the time is not a number, or when it is negative
Example
Section titled “Example”await queue.seek(60);setRepeatMode()
Section titled “setRepeatMode()”setRepeatMode(mode?): RepeatMode;Set the repeat mode of the guild queue.
Toggle mode (Disabled -> Song -> Queue -> Disabled ->...) if mode is undefined
Parameters
Section titled “Parameters”The repeat modes (toggle if undefined)
Returns
Section titled “Returns”The new repeat mode
Throws
Section titled “Throws”DisTubeError When the mode is not a valid RepeatMode
setVolume()
Section titled “setVolume()”setVolume(percent): Queue;Set the guild stream’s volume
Parameters
Section titled “Parameters”percent
Section titled “percent”number
The percentage of volume you want to set
Returns
Section titled “Returns”Queue
The guild queue
Throws
Section titled “Throws”DisTubeError When the volume is not a number, or when it is negative
shuffle()
Section titled “shuffle()”shuffle(): Promise<Queue>;Shuffle the queue’s songs
Returns
Section titled “Returns”Promise<Queue>
The guild queue
skip()
Section titled “skip()”skip(options?): Promise<Song<unknown>>;Skip the playing song if there is a next song in the queue. true and there is no up next song, DisTube will add and
play a related song.
Parameters
Section titled “Parameters”options?
Section titled “options?”Skip options
Returns
Section titled “Returns”Promise<Song<unknown>>
The song will skip to
Throws
Section titled “Throws”DisTubeError When there is no up next song, or when the position is out of the bounds of the queue
Example
Section titled “Example”await queue.skip();stop()
Section titled “stop()”stop(): Promise<void>;Stop the guild stream and delete the queue
Returns
Section titled “Returns”Promise<void>
A promise that resolves when the queue is stopped
toggleAutoplay()
Section titled “toggleAutoplay()”toggleAutoplay(): boolean;Toggle autoplay mode
Returns
Section titled “Returns”boolean
Autoplay mode state