MemoryQueue
Table of Contentsโ
Class Definitionโ
export class MemoryQueue extends Array<Track> implements IQueue {}
Propertiesโ
Property Type Description currentTrack| nullThe current track. guildIdstring The guild ID. managerManagerThe Manager instance. previousTrack[]| []The previous tracks.
Constructorโ
new MemoryQueue(guildId: string, manager: Manager)
Parameter Type Description Optional guildIdstring The guild ID managerManagerThe Manager instance.
Methodsโ
add()โ
async add(track: Track | Track[], offset?: number): Promise<void>Adds a track or an array of tracks to the queue.
Parametersโ
Parameter Type Description Optional trackTrack|Track[]The track or an array of tracks to add to the queue. offsetnumber The offset to add the track at.
addPrevious()โ
async addPrevious(track: Track | Track[]): Promise<void>Adds one or more tracks to the "previous" history list.
Parametersโ
Parameter Type Description Optional trackTrack|Track[]The track to add to the "previous" history list.
clear()โ
async clear(): Promise<void>Clears the queue.
clearPrevious()โ
async clearPrevious(): Promise<void>Clears the "previous" history list.
dequeue()โ
async dequeue(): Promise<Track | undefined>Removes the first element from the queue.
Returnsโ
Type Description Track| undefinedThe first element in the queue, or undefinedif the queue is empty.
duration()โ
async duration(): Promise<number>Returns the total duration of the queue.
Returnsโ
Type Description number The total duration of the queue in milliseconds.
enqueueFront()โ
async enqueueFront(track: Track | Track[]): Promise<void>Adds a track or an array of tracks to the front of the queue.
Parametersโ
Parameter Type Description Optional trackTrack|Track[]The track or an array of tracks to add to the queue.
everyAsync()โ
async everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>Tests whether all elements in the queue pass the test implemented by the provided function.
Parametersโ
Parameter Type Description Optional callbackFunction The callback function. Returnsโ
Type Description boolean trueif the callback function returns a truthy value for every element in the queue, otherwisefalse.
filterAsync()โ
async filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>Filters the queue.
Parametersโ
Parameter Type Description Optional callbackFunction The callback function. Returnsโ
Type Description Track| undefinedThe first element in the queue, or undefinedif the queue is empty.
findAsync()โ
async findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>Returns the first element in the queue that satisfies the provided testing function.
Parametersโ
Parameter Type Description Optional callbackFunction The callback function. Returnsโ
Type Description Track| undefinedThe first element in the queue, or undefinedif the queue is empty.
getCurrent()โ
async getCurrent(): Promise<Track | null>Returns the currently playing track.
Returnsโ
Type Description Track| nullThe current track, or nullif no track is playing.