✨ Fix createProgressBar method
This commit is contained in:
parent
90f9beca37
commit
09eddf27c7
1 changed files with 25 additions and 21 deletions
|
@ -650,6 +650,31 @@ class Player {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates progress bar of the current song
|
||||||
|
* @param {Discord.Snowflake} guildID
|
||||||
|
* @returns {String}
|
||||||
|
*/
|
||||||
|
createProgressBar (guildID) {
|
||||||
|
// Gets guild queue
|
||||||
|
const queue = this.queues.find((g) => g.guildID === guildID)
|
||||||
|
if (!queue) return
|
||||||
|
// Stream time of the dispatcher
|
||||||
|
const currentStreamTime = queue.voiceConnection.dispatcher.streamTime
|
||||||
|
// Total stream time
|
||||||
|
const totalTime = queue.playing.durationMS
|
||||||
|
// Stream progress
|
||||||
|
const index = Math.round((currentStreamTime / totalTime) * 15)
|
||||||
|
// conditions
|
||||||
|
if ((index >= 1) && (index <= 15)) {
|
||||||
|
const bar = '▬▬▬▬▬▬▬▬▬▬▬▬▬▬'.split('')
|
||||||
|
bar.splice(index, 0, '🔘')
|
||||||
|
return bar.join('')
|
||||||
|
} else {
|
||||||
|
return '🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the voice state update event
|
* Handle the voice state update event
|
||||||
* @ignore
|
* @ignore
|
||||||
|
@ -674,27 +699,6 @@ class Player {
|
||||||
queue.emit('channelEmpty')
|
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
|
* Play a stream in a channel
|
||||||
|
|
Loading…
Reference in a new issue