show duration in queue and now playing
This commit is contained in:
parent
f76f42244f
commit
ba5aaf12e5
|
@ -23,7 +23,6 @@ bot.once('ready', () => {
|
|||
const prefix = ';';
|
||||
const embedColor = 0xa0ffa5;
|
||||
const foggyImg = 'https://cdn.discordapp.com/attachments/789023763396165633/898908687299657728/552bb191-93e3-4eaa-b935-d5031f3845e7.gif';
|
||||
const ffprobeRegex = /Audio: ([^,\n]+), (\d+) ?Hz, ?([^,\n]+), ?([^,\n]+)(, ?([^,\n]+))?/;
|
||||
|
||||
async function checkVoiceChannel(msg) {
|
||||
if (!msg.guild) return;
|
||||
|
@ -157,6 +156,10 @@ function rawYTDLQueue(info) {
|
|||
return song;
|
||||
}
|
||||
|
||||
function formatTime(t) {
|
||||
return `${Math.floor(t / 60).toString().padStart(2, '0')}:${Math.floor(t % 60).toString().padStart(2, '0')}`
|
||||
}
|
||||
|
||||
async function queueUp(url, id) {
|
||||
if (!queue[id]) queue[id] = [];
|
||||
|
||||
|
@ -246,7 +249,7 @@ bot.on('messageCreate', async (msg) => {
|
|||
if (q.length === 0) {
|
||||
msg.channel.send('no songs queued!');
|
||||
} else {
|
||||
msg.channel.send('```' + q.map((m, i) => `${i === 0 ? 'now playing:' : i + '.'} ${m.title}`).join('\n') + '```');
|
||||
msg.channel.send('```' + q.map((m, i) => `${i === 0 ? 'now playing:' : i + '.'} ${m.title} ${(m.duration !== 0) ? formatTime(m.duration) : ''}`).join('\n') + '```');
|
||||
}
|
||||
} else if (cmd === 'np' || cmd === 'nowplaying') {
|
||||
const song = (queue[msg.guild.id] || [])[0];
|
||||
|
@ -261,6 +264,7 @@ bot.on('messageCreate', async (msg) => {
|
|||
progressStr = '🔘 `buffering,,`';
|
||||
} else {
|
||||
progressStr = `${'▬'.repeat(Math.floor(Math.abs(progress) * progressLength))}🔘${'▬'.repeat(Math.floor((1 - Math.abs(progress)) * progressLength))}`;
|
||||
progressStr += `\n\`${formatTime((Date.now() - (playerStartTime[msg.guild.id] || 0)) / 1000)}\`/\`${formatTime(song.duration)}\``
|
||||
}
|
||||
|
||||
let embed = new Discord.MessageEmbed()
|
||||
|
|
Reference in New Issue