From 789486747ba3d9f9f6a6bf2cabe92aa75be64ad5 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Mon, 10 Jul 2023 19:55:37 +0200 Subject: [PATCH 1/5] fix: Removed "Failed" heading from reply --- commands/queue.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/queue.js b/commands/queue.js index acb9a99..2a1fbec 100644 --- a/commands/queue.js +++ b/commands/queue.js @@ -30,7 +30,7 @@ module.exports = { let queueString = ''; if (!queue) { - queueString = `**Failed**\nThere are no tracks in the queue. Add tracks with \`/play\`!`; + queueString = `There are no tracks in the queue. Add tracks with \`/play\`!`; return await interaction.editReply({ embeds: [ new EmbedBuilder() From 955bda9d693fa10119deb7026bc0e4e1d25a49c1 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Mon, 10 Jul 2023 19:56:27 +0200 Subject: [PATCH 2/5] fix: format track amount as bold instead of code --- commands/play.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/play.js b/commands/play.js index b2c7008..18147f9 100644 --- a/commands/play.js +++ b/commands/play.js @@ -71,9 +71,9 @@ module.exports = { .setDescription( `**Added playlist to queue**\n\`[${ track.duration - }]\` **[${track.title}](${track.url})**\n\nAnd \`${ + }]\` **[${track.title}](${track.url})**\n\nAnd **${ searchResult.tracks.length - 1 - }\` more tracks... \`/queue\` to view all.` + }** more tracks... \`/queue\` to view all.` ) .setThumbnail(track.thumbnail) .setColor(embedColors.colorSuccess) From 0a7f31a5652fd5b5e6758b939be621de0b01ff70 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Mon, 10 Jul 2023 20:03:17 +0200 Subject: [PATCH 3/5] fix: add page number also on empty queue --- commands/queue.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/commands/queue.js b/commands/queue.js index 2a1fbec..38e56ed 100644 --- a/commands/queue.js +++ b/commands/queue.js @@ -40,6 +40,9 @@ module.exports = { }) .setDescription(`**Queue**\n${queueString}`) .setColor(embedColors.colorInfo) + .setFooter({ + text: `Page 1 of 1` + }) ] }); } From b8bd552335a20d5cf5cd5cf86d11e7bdbed863bc Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Mon, 10 Jul 2023 21:08:14 +0200 Subject: [PATCH 4/5] fix: handle unsupported YouTube live stream source --- commands/play.js | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/commands/play.js b/commands/play.js index 18147f9..85ed422 100644 --- a/commands/play.js +++ b/commands/play.js @@ -45,6 +45,22 @@ module.exports = { }); } + if ( + searchResult.tracks[0].raw.live && + searchResult.tracks[0].raw.duration === 0 && + searchResult.tracks[0].source === 'youtube' + ) { + return await interaction.editReply({ + embeds: [ + new EmbedBuilder() + .setDescription( + `**Unsupported Source**\nThis audio source is a YouTube live stream, which is currently not a supported format.\n\n_If you think that this is incorrect, please submit a bug report in the bot [support server](https://discord.gg/t6Bm8wPpXB)._` + ) + .setColor(embedColors.colorWarning) + ] + }); + } + const { track } = await player.play( interaction.member.voice.channel, searchResult, @@ -60,6 +76,16 @@ module.exports = { } ); + if (track.source === 'arbitrary') { + track.thumbnail = + 'https://raw.githubusercontent.com/mariusbegby/cadence-discord-bot/main/icons/Cadence-icon-rounded-128px.png'; + } + + let durationFormat = + track.raw.duration === 0 || track.duration === '0:00' + ? '' + : `\`[${track.duration}]\``; + if (searchResult.playlist && searchResult.tracks.length > 1) { return await interaction.editReply({ embeds: [ @@ -69,9 +95,9 @@ module.exports = { iconURL: interaction.user.avatarURL() }) .setDescription( - `**Added playlist to queue**\n\`[${ - track.duration - }]\` **[${track.title}](${track.url})**\n\nAnd **${ + `**Added playlist to queue**\n${durationFormat} **[${ + track.title + }](${track.url})**\n\nAnd **${ searchResult.tracks.length - 1 }** more tracks... \`/queue\` to view all.` ) @@ -89,7 +115,7 @@ module.exports = { iconURL: interaction.user.avatarURL() }) .setDescription( - `**Added to queue**\n\`[${track.duration}]\` **[${track.title}](${track.url})**` + `**Added to queue**\n${durationFormat} **[${track.title}](${track.url})**` ) .setThumbnail(track.thumbnail) .setColor(embedColors.colorSuccess) From ebe4f7419a0d218d4f333ba13b9b71c4f6e39fee Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Mon, 10 Jul 2023 21:08:39 +0200 Subject: [PATCH 5/5] 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()