Skip to content

Commit

Permalink
feat: add createProgressBar (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
twlite authored Jun 24, 2020
1 parent 347750e commit c6625a0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c6625a0

Please sign in to comment.