QueueChangesWatcher

Type: class / object

Queue Changes Watcher can be used, to log whenever a change in the QUEUE (client sided) is made.

You can use also use it to sync dashboard actions, if your database does NOT "allow" listeners for database entry changes.

Parameter
Type
Required
Description

X

Interface

export interface QueueChangesWatcher {
    /** get a Value (MUST RETURN UNPARSED!) */
    tracksAdd: (guildId:string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue:StoredQueue, newStoredQueue: StoredQueue) => any;
    /** Set a value inside a guildId (MUST BE UNPARSED) */
    tracksRemoved: (guildId:string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue:StoredQueue, newStoredQueue: StoredQueue) => any;
    /** Set a value inside a guildId (MUST BE UNPARSED) */
    shuffled: (guildId:string, oldStoredQueue:StoredQueue, newStoredQueue: StoredQueue) => any;
}

Example

export class myCustomWatcher implements QueueChangesWatcher {
    private client:BotClient;
    constructor(client:BotClient) {
        this.client = client;
    }
    shuffled(guildId, oldStoredQueue, newStoredQueue) {
        console.log(`${this.client.guilds.cache.get(guildId)?.name || guildId}: Queue got shuffled`)    
    }
    tracksAdd(guildId, tracks, position, oldStoredQueue, newStoredQueue) {
        console.log(`${this.client.guilds.cache.get(guildId)?.name || guildId}: ${tracks.length} Tracks got added into the Queue at position #${position}`);    
    }
    tracksRemoved(guildId, tracks, position, oldStoredQueue, newStoredQueue) {
        console.log(`${this.client.guilds.cache.get(guildId)?.name || guildId}: ${tracks.length} Tracks got removed from the Queue at position #${position}`);
    }
}

Last updated