RedisQueue
Table of Contentsโ
Class Definitionโ
export class RedisQueue implements IQueue {}
Propertiesโ
Property Type Description redisRedisClientThe Redis client. redisPrefixstring The Redis prefix.
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.
destroy()โ
async destroy(): Promise<void>Destroys the queue and releases all resources. After calling this method, the queue must not be used again.
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.
getPrevious()โ
async getPrevious(): Promise<Track[]>Returns the previous tracks.
Returnsโ
Type Description Track[]The previous tracks.
getSlice()โ
async getSlice(start?: number, end?: number): Promise<Track[]>Returns a slice of the queue.
Parametersโ
Parameter Type Description Optional startnumber Start index of the range of tracks to remove. endnumber End index (exclusive) of the range of tracks to remove. Returnsโ
Type Description Track[]The tracks in the queue.
getTracks()โ
async getTracks(): Promise<Track[]>Returns the tracks in the queue.
Returnsโ
Type Description Track[]The tracks in the queue.
mapAsync()โ
async mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>Maps the queue to an array of values.
Parametersโ
Parameter Type Description Optional callbackFunction The callback function.
modifyAt()โ
async modifyAt(start: number, deleteCount = 0, ...items: Track[]): Promise<Track[]>Modifies a range of tracks in the queue.
Parametersโ
Parameter Type Description Optional startnumber Start index of the range of tracks to remove. deleteCountnumber Number of tracks to remove. itemsTrack[]Array of tracks to insert. Returnsโ
Type Description Track[]The tracks in the queue.
popPrevious()โ
async popPrevious(): Promise<Track | null>Removes and returns the last track from the "previous" history list.
Returnsโ
Type Description Track| nullThe last track in the "previous" history list, or nullif the list is empty.
remove()โ
async remove(position?: number): Promise<Track[]>async remove(start: number, end: number): Promise<Track[]>Removes a track or a range of tracks from the queue.
Parametersโ
Parameter Type Description Optional positionnumber Index of the track to remove. startnumber Start index of the range of tracks to remove. endnumber End index (exclusive) of the range of tracks to remove. Returnsโ
Type Description Track[]The removed track(s).
roundRobinShuffle()โ
async roundRobinShuffle(): Promise<void>Shuffles the queue to play tracks requested by each user one by one.
setCurrent()โ
async setCurrent(track: Track | null): Promise<void>Sets the currently playing track.
Parametersโ
Parameter Type Description Optional trackTrack| nullThe track to set as the current track.
setPrevious()โ
async setPrevious(tracks: Track[]): Promise<void>Sets the previous tracks.
Parametersโ
Parameter Type Description Optional tracksTrack[]The previous tracks to set.
shuffle()โ
async shuffle(): Promise<void>Shuffles the queue.
size()โ
async size(): Promise<number>Returns the size of the queue not including the current track.
Returnsโ
Type Description number The size of the queue.
someAsync()โ
async someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>Tests whether at least one element in the queue passes 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 at least one element in the queue, otherwisefalse.
totalSize()โ
async totalSize(): Promise<number>Returns the total size of the queue.
Returnsโ
Type Description number The total size of the queue.
userBlockShuffle()โ
async userBlockShuffle(): Promise<void>Shuffles the queue to play tracks requested by each user one block at a time.