From ebe4f7419a0d218d4f333ba13b9b71c4f6e39fee Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Mon, 10 Jul 2023 21:08:39 +0200 Subject: [PATCH] fix: Better handling and formatting of duration --- commands/queue.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/commands/queue.js b/commands/queue.js index 38e56ed..6554193 100644 --- a/commands/queue.js +++ b/commands/queue.js @@ -68,9 +68,14 @@ module.exports = { queueString = queue.tracks.data .slice(page * 10, page * 10 + 10) .map((track, index) => { - return `**${page * 10 + index + 1}.** \`[${ - track.duration - }]\` [${track.title}](${track.url})`; + let durationFormat = + track.raw.duration === 0 || track.duration === '0:00' + ? '' + : `\`[${track.duration}]\``; + + return `**${page * 10 + index + 1}.** ${durationFormat} [${ + track.title + }](${track.url})`; }) .join('\n'); } @@ -98,6 +103,13 @@ module.exports = { length: 13 }); + if ( + currentTrack.raw.duration === 0 || + currentTrack.duration === '0:00' + ) { + bar = 'No duration available.'; + } + return await interaction.editReply({ embeds: [ new EmbedBuilder()