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 prefix = ';';
|
||||||
const embedColor = 0xa0ffa5;
|
const embedColor = 0xa0ffa5;
|
||||||
const foggyImg = 'https://cdn.discordapp.com/attachments/789023763396165633/898908687299657728/552bb191-93e3-4eaa-b935-d5031f3845e7.gif';
|
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) {
|
async function checkVoiceChannel(msg) {
|
||||||
if (!msg.guild) return;
|
if (!msg.guild) return;
|
||||||
|
@ -157,6 +156,10 @@ function rawYTDLQueue(info) {
|
||||||
return song;
|
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) {
|
async function queueUp(url, id) {
|
||||||
if (!queue[id]) queue[id] = [];
|
if (!queue[id]) queue[id] = [];
|
||||||
|
|
||||||
|
@ -246,7 +249,7 @@ bot.on('messageCreate', async (msg) => {
|
||||||
if (q.length === 0) {
|
if (q.length === 0) {
|
||||||
msg.channel.send('no songs queued!');
|
msg.channel.send('no songs queued!');
|
||||||
} else {
|
} 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') {
|
} else if (cmd === 'np' || cmd === 'nowplaying') {
|
||||||
const song = (queue[msg.guild.id] || [])[0];
|
const song = (queue[msg.guild.id] || [])[0];
|
||||||
|
@ -261,6 +264,7 @@ bot.on('messageCreate', async (msg) => {
|
||||||
progressStr = '🔘 `buffering,,`';
|
progressStr = '🔘 `buffering,,`';
|
||||||
} else {
|
} else {
|
||||||
progressStr = `${'▬'.repeat(Math.floor(Math.abs(progress) * progressLength))}🔘${'▬'.repeat(Math.floor((1 - Math.abs(progress)) * progressLength))}`;
|
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()
|
let embed = new Discord.MessageEmbed()
|
||||||
|
|
Reference in New Issue