Queue
Manages the list of tracks waiting to be played. Supports adding, removing, shuffling, and manipulating tracks.
The Queue class is a specialized array-like structure that holds the tracks scheduled for playback. It provides helper methods for common music bot operations like shuffling, moving tracks, or clearing the queue.
Properties
Queue Properties
State and contents of the track queue.
State
The number of tracks currently in the queue.
The total duration of all tracks in the queue (in milliseconds).
Duration of the queue + the remaining time of the currently playing track.
True if the queue has no tracks.
Accessors
The first track in the queue (next to play).
The last track in the queue.
Returns a copy of all tracks in the queue array.
Methods
add(track)
add(track)#
→voidAdds one or more tracks to the end of the queue. Respects maxSize and allowDuplicates settings.
The track(s) to add.
remove(index)
remove(index)#
→Track | undefinedRemoves and returns the track at the specified index.
The index to remove. Defaults to 0.
clear()
shuffle()
insert(index, track)
Inserts one or more tracks at a specific position in the queue.
The index to insert at.
The track(s) to insert.
move(from, to)
move(from, to)#
→booleanMoves a track from one position to another.
The index of the track to move.
The index where the track should be placed.
get(position)
get(position)#
→Track | undefinedRetrieves the track at a specific index without removing it.
The index of the track.
has(track)
has(track)#
→booleanChecks if a specific track object exists in the queue.
The track object to check.
removeDuplicates()
removeDuplicates()#
→booleanRemoves duplicate tracks from the queue based on their encoded string. Returns true if duplicates were found and removed.
reverse()
sortByTitle()
sortByTitle()#
→voidSorts the queue alphabetically by track title (A-Z).
sortByAuthor()
sortByAuthor()#
→voidSorts the queue alphabetically by artist/author name (A-Z).
sortByDuration()
sortByDuration()#
→voidSorts the queue by track duration (shortest to longest).