From c6625a02d8c17057c251cd3f5f5b66c0c13a7cbc Mon Sep 17 00:00:00 2001 From: Snowflake <46562212+Snowflake107@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:59:33 +0545 Subject: [PATCH] feat: add createProgressBar (#33) --- src/Player.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Player.js b/src/Player.js index b5cc4a3..bddec56 100644 --- a/src/Player.js +++ b/src/Player.js @@ -674,6 +674,27 @@ class Player { queue.emit('channelEmpty') } } + + /** + * Creates progress bar of the current song + * @param {Queue} queue Queue of the current server + * @returns {String} + */ + createProgressBar(queue) { + // stream time of the dispatcher + const currentStreamTime = queue.voiceConnection.dispatcher.streamTime + // total stream length + const totalLength = queue.tracks[0].durationMS + // stream progress + let index = Math.round((currentStreamTime / totalLength) * 15) + // conditions + if ((index >= 1) && (index <= 15)) { + let bar = `▬▬▬▬▬▬▬▬▬▬▬▬▬▬`.split("") + return bar.splice(index, 0, "🔘").join("") + } else { + return `🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬` + } + } /** * Play a stream in a channel