Add currentTime and totalTime options to progress bar

Closes #281
This commit is contained in:
Androz2091 2021-02-19 08:21:36 +01:00
parent da8b5bc608
commit 5223a599ba

View file

@ -1002,8 +1002,10 @@ 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 {number} [options.currentTime]
* @param {number} [options.totalTime]
* @returns {string}
*/
createProgressBar (message, options) {
@ -1012,9 +1014,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 && typeof options.currentTime === 'number' ? options.currentTime : queue.currentStreamTime
// Total stream time
const totalTime = queue.playing.durationMS
const totalTime = options && typeof options.totalTime === 'number' ? options.totalTime : queue.playing.durationMS
// Stream progress
const index = Math.round((currentStreamTime / totalTime) * 15)
// conditions