From 1af218f3403622e4164a3e52819f3e8690cb78e6 Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Fri, 19 Feb 2021 08:25:06 +0100 Subject: [PATCH] :sparkles: Add queue option to progress bar #281 --- src/Player.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Player.js b/src/Player.js index 38f01f9..3bbcd77 100644 --- a/src/Player.js +++ b/src/Player.js @@ -1002,8 +1002,9 @@ class Player extends EventEmitter { /** * Create a progress bar for the queue of the server. * @param {Discord.Message} message - * @param {Object} options - * @param {boolean} options.timecodes + * @param {Object} [options] + * @param {boolean} [options.timecodes] Whether or not to show timecodes in the progress bar + * @param {boolean} [options.queue] Whether to show the progress bar for the whole queue (if false, only the current song) * @returns {string} */ createProgressBar (message, options) { @@ -1012,9 +1013,9 @@ class Player extends EventEmitter { if (!queue) return const timecodes = options && typeof options === 'object' ? options.timecodes : false // Stream time of the dispatcher - const currentStreamTime = queue.currentStreamTime + const currentStreamTime = options && options.queue ? queue.previousTracks.map((t) => t.durationMS).reduce((p, c) => p + c) + queue.currentStreamTime : queue.currentStreamTime // Total stream time - const totalTime = queue.playing.durationMS + const totalTime = options && options.queue ? queue.tracks.map((t) => t.durationMS).reduce((p, c) => p + c) : queue.playing.durationMS // Stream progress const index = Math.round((currentStreamTime / totalTime) * 15) // conditions