From 783f6ade356011c7563091305e278a5112db49e9 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sat, 15 Jul 2023 12:48:47 +0200 Subject: [PATCH 01/16] fix: Add more configurable options for loop and autoplay icons --- config.json.example | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.json.example b/config.json.example index e935119..f115008 100644 --- a/config.json.example +++ b/config.json.example @@ -55,6 +55,10 @@ "previousTrack": "⏮️", "pauseResumeTrack": "⏯️", "shuffleQueue": "🔀", + "loop": "🔁", + "autoplay": "♾️", + "looping": "🔁", + "autoplaying": "♾️", "skipped": "⏭️", "back": "⏮️", "pauseResumed": "⏯️", From 798b65b7810864488319c297af8978a9317bbe39 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sat, 15 Jul 2023 13:03:04 +0200 Subject: [PATCH 02/16] fix: Added period after sentence in message for toggling filters. --- commands/filters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/filters.js b/commands/filters.js index a871694..19d310a 100644 --- a/commands/filters.js +++ b/commands/filters.js @@ -164,7 +164,7 @@ module.exports = { ).label }\`` ) - .join(', ')}` + .join(', ')}.` ) .setColor(embedColors.colorSuccess) ], From 18504f46d77bb2a49f07c0c3d3c9cb2804163f04 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sat, 15 Jul 2023 13:03:22 +0200 Subject: [PATCH 03/16] fix: added /loop command in /help message --- commands/help.js | 1 + 1 file changed, 1 insertion(+) diff --git a/commands/help.js b/commands/help.js index 29a6c58..b7dee3a 100644 --- a/commands/help.js +++ b/commands/help.js @@ -17,6 +17,7 @@ module.exports = { '- `/pause` - Pause or resume the current track.\n' + '- `/queue` `[page]` - Show the list of tracks added to the queue.\n' + `- \`/nowplaying\` - ${embedIcons.new} Show information about the track currently playing.\n` + + `- \`/loop\` \`mode\` - ${embedIcons.new} Toggle looping a track or the whole queue.\n` + `- \`/filters\` - ${embedIcons.beta} Toggle various audio filters during playback.\n` + '- `/volume` `[percentage]` - Show or set the playback volume for tracks.\n' + '- `/skip` `[trackNumber]` - Skip current or specified track.\n' + From 7e1054dbdad90e97ab058ade518146298296f6ab Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sat, 15 Jul 2023 14:46:25 +0200 Subject: [PATCH 04/16] fix: fixed /guilds command slicing array before sorting --- system-commands/guilds.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/system-commands/guilds.js b/system-commands/guilds.js index 77ea5a5..1913166 100644 --- a/system-commands/guilds.js +++ b/system-commands/guilds.js @@ -31,9 +31,12 @@ module.exports = { memberCount: guild.memberCount }; }) - .slice(0, 50) .sort((a, b) => b.memberCount - a.memberCount) - .map((guild, index) => `${index + 1}. \`${guild.name} (#${guild.memberCount})\``) + .slice(0, 50) + .map( + (guild, index) => + `${index + 1}. \`${guild.name} (#${guild.memberCount})\`` + ) .join('\n'); let embedDescription = `**${embedIcons.bot} ${ From 457dfa1ad77f2f65049f779b10d778679d52e2c4 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sat, 15 Jul 2023 15:17:20 +0200 Subject: [PATCH 05/16] fix: added configurable options for muted icon --- config.json.example | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.json.example b/config.json.example index f115008..a744e0f 100644 --- a/config.json.example +++ b/config.json.example @@ -64,7 +64,9 @@ "pauseResumed": "⏯️", "shuffled": "🔀", "volume": "🔊", + "volumeIsMuted": "🔇", "volumeChanged": "🔊", + "volumeMuted": "🔇", "queue": "🎶" }, "filterThreadAmount": "2", From 7bc50d6a8422f74b1329aad3e4152b6acd948b7a Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sat, 15 Jul 2023 15:36:40 +0200 Subject: [PATCH 06/16] fix: Set quality and highWaterMark in ytdlOptions --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index 68413db..c48e4d1 100644 --- a/index.js +++ b/index.js @@ -37,6 +37,8 @@ for (const file of systemCommandFiles) { const player = new Player(client, { useLegacyFFmpeg: false, ytdlOptions: { + quality: 'highestaudio', + highWaterMark: 1 << 25, requestOptions: { headers: { cookie: process.env.YOUTUBE_COOKIE || '' From d5eb032543f8b70a99e9ec8fcdbfdfe072d375fb Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sat, 15 Jul 2023 15:37:54 +0200 Subject: [PATCH 07/16] fix: Improved user messages for muted audio in /volume --- commands/volume.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/commands/volume.js b/commands/volume.js index ed92d66..9be0296 100644 --- a/commands/volume.js +++ b/commands/volume.js @@ -45,11 +45,17 @@ module.exports = { const volume = interaction.options.getNumber('percentage'); if (!volume && volume !== 0) { + const currentVolume = queue.node.volume; + return await interaction.editReply({ embeds: [ new EmbedBuilder() .setDescription( - `**${embedIcons.volume} Playback volume**\nThe playback volume is currently set to \`${queue.node.volume}%\`.` + `**${ + currentVolume === 0 + ? embedIcons.volumeIsMuted + : embedIcons.volume + } Playback volume**\nThe playback volume is currently set to \`${currentVolume}%\`.` ) .setColor(embedColors.colorInfo) ] @@ -72,11 +78,13 @@ module.exports = { embeds: [ new EmbedBuilder() .setAuthor({ - name: interaction.member.nickname || interaction.user.username, + name: + interaction.member.nickname || + interaction.user.username, iconURL: interaction.user.avatarURL() }) .setDescription( - `**${embedIcons.volumeChanged} Audio muted**\nPlayback audio has been muted, because volume was set to \`${volume}%\`.` + `**${embedIcons.volumeMuted} Audio muted**\nPlayback audio has been muted, because volume was set to \`${volume}%\`.` ) .setColor(embedColors.colorSuccess) ] @@ -87,7 +95,9 @@ module.exports = { embeds: [ new EmbedBuilder() .setAuthor({ - name: interaction.member.nickname || interaction.user.username, + name: + interaction.member.nickname || + interaction.user.username, iconURL: interaction.user.avatarURL() }) .setDescription( From 845002595f1529f51f2479e9114363bd0b384a6c Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sat, 15 Jul 2023 15:45:53 +0200 Subject: [PATCH 08/16] fix: Added configurable icon for loop action --- config.json.example | 1 + 1 file changed, 1 insertion(+) diff --git a/config.json.example b/config.json.example index a744e0f..7947425 100644 --- a/config.json.example +++ b/config.json.example @@ -56,6 +56,7 @@ "pauseResumeTrack": "⏯️", "shuffleQueue": "🔀", "loop": "🔁", + "loopAction": "🔁", "autoplay": "♾️", "looping": "🔁", "autoplaying": "♾️", From c59fce19c74bcb0f069807e02e2a1612e9241bad Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sat, 15 Jul 2023 18:20:14 +0200 Subject: [PATCH 09/16] fix: /nowplaying showing 'unavailable' views when track.views is set properly --- commands/nowplaying.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commands/nowplaying.js b/commands/nowplaying.js index 21481cf..82486eb 100644 --- a/commands/nowplaying.js +++ b/commands/nowplaying.js @@ -60,11 +60,13 @@ module.exports = { ]); const currentTrack = queue.currentTrack; + let author = currentTrack.author ? currentTrack.author : 'Unavailable'; if (author === 'cdn.discordapp.com') { author = 'Unavailable'; } let plays = currentTrack.views !== 0 ? currentTrack.views : 0; + if ( plays === 0 && currentTrack.metadata.bridge && @@ -72,9 +74,10 @@ module.exports = { currentTrack.metadata.bridge.views !== undefined ) { plays = currentTrack.metadata.bridge.views; - } else { + } else if (plays === 0) { plays = 'Unavailable'; } + const source = sourceStringsFormatted.get(currentTrack.raw.source) ?? 'Unavailable'; From 1f1c64284c21823dda673646f6995757cedda62c Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sun, 16 Jul 2023 01:18:47 +0200 Subject: [PATCH 10/16] Formatting --- commands/filters.js | 8 +++++-- commands/pause.js | 53 +++++++++++++++++++-------------------------- commands/queue.js | 14 +++++++----- commands/remove.js | 4 +++- commands/skip.js | 8 +++++-- 5 files changed, 46 insertions(+), 41 deletions(-) diff --git a/commands/filters.js b/commands/filters.js index 19d310a..37229fa 100644 --- a/commands/filters.js +++ b/commands/filters.js @@ -129,7 +129,9 @@ module.exports = { embeds: [ new EmbedBuilder() .setAuthor({ - name: interaction.member.nickname || interaction.user.username, + name: + interaction.member.nickname || + interaction.user.username, iconURL: interaction.user.avatarURL() }) .setDescription( @@ -148,7 +150,9 @@ module.exports = { embeds: [ new EmbedBuilder() .setAuthor({ - name: interaction.member.nickname || interaction.user.username, + name: + interaction.member.nickname || + interaction.user.username, iconURL: interaction.user.avatarURL() }) .setDescription( diff --git a/commands/pause.js b/commands/pause.js index 76e17f6..b064e18 100644 --- a/commands/pause.js +++ b/commands/pause.js @@ -56,36 +56,27 @@ module.exports = { // change paused state to opposite of current state queue.node.setPaused(!queue.node.isPaused()); - if (queue.node.isPaused()) { - return await interaction.editReply({ - embeds: [ - new EmbedBuilder() - .setAuthor({ - name: interaction.member.nickname || interaction.user.username, - iconURL: interaction.user.avatarURL() - }) - .setDescription( - `**${embedIcons.pauseResumed} Paused track**\n**${durationFormat} [${queue.currentTrack.title}](${queue.currentTrack.url})**` - ) - .setThumbnail(queue.currentTrack.thumbnail) - .setColor(embedColors.colorSuccess) - ] - }); - } else { - return await interaction.editReply({ - embeds: [ - new EmbedBuilder() - .setAuthor({ - name: interaction.member.nickname || interaction.user.username, - iconURL: interaction.user.avatarURL() - }) - .setDescription( - `**${embedIcons.pauseResumed} Resumed track**\n**${durationFormat} [${queue.currentTrack.title}](${queue.currentTrack.url})**` - ) - .setThumbnail(queue.currentTrack.thumbnail) - .setColor(embedColors.colorSuccess) - ] - }); - } + return await interaction.editReply({ + embeds: [ + new EmbedBuilder() + .setAuthor({ + name: + interaction.member.nickname || + interaction.user.username, + iconURL: interaction.user.avatarURL() + }) + .setDescription( + `**${embedIcons.pauseResumed} ${ + queue.node.isPaused() + ? 'Paused Track' + : 'Resumed track' + }**\n**${durationFormat} [${ + queue.currentTrack.title + }](${queue.currentTrack.url})**` + ) + .setThumbnail(queue.currentTrack.thumbnail) + .setColor(embedColors.colorSuccess) + ] + }); } }; diff --git a/commands/queue.js b/commands/queue.js index 5c81d5c..3a3d2d7 100644 --- a/commands/queue.js +++ b/commands/queue.js @@ -41,7 +41,9 @@ module.exports = { embeds: [ new EmbedBuilder() .setDescription( - `**${embedIcons.warning} Oops!**\nPage \`${pageIndex + 1}\` is not a valid page number.\n\nThe queue is currently empty, first add some tracks with \`/play\`!` + `**${embedIcons.warning} Oops!**\nPage \`${ + pageIndex + 1 + }\` is not a valid page number.\n\nThe queue is currently empty, first add some tracks with \`/play\`!` ) .setColor(embedColors.colorWarning) ] @@ -74,7 +76,9 @@ module.exports = { embeds: [ new EmbedBuilder() .setDescription( - `**${embedIcons.warning} Oops!**\nPage \`${pageIndex + 1}\` is not a valid page number.\n\nThere are only a total of \`${totalPages}\` pages in the queue.` + `**${embedIcons.warning} Oops!**\nPage \`${ + pageIndex + 1 + }\` is not a valid page number.\n\nThere are only a total of \`${totalPages}\` pages in the queue.` ) .setColor(embedColors.colorWarning) ] @@ -92,9 +96,9 @@ module.exports = { ? '' : `\`${track.duration}\``; - return `**${pageIndex * 10 + index + 1}.** ${durationFormat} **[${ - track.title - }](${track.url})**`; + return `**${ + pageIndex * 10 + index + 1 + }.** ${durationFormat} **[${track.title}](${track.url})**`; }) .join('\n'); } diff --git a/commands/remove.js b/commands/remove.js index bfe792f..6a4d1e4 100644 --- a/commands/remove.js +++ b/commands/remove.js @@ -67,7 +67,9 @@ module.exports = { embeds: [ new EmbedBuilder() .setAuthor({ - name: interaction.member.nickname || interaction.user.username, + name: + interaction.member.nickname || + interaction.user.username, iconURL: interaction.user.avatarURL() }) .setDescription( diff --git a/commands/skip.js b/commands/skip.js index d8371d9..fff30c1 100644 --- a/commands/skip.js +++ b/commands/skip.js @@ -67,7 +67,9 @@ module.exports = { embeds: [ new EmbedBuilder() .setAuthor({ - name: interaction.member.nickname || interaction.user.username, + name: + interaction.member.nickname || + interaction.user.username, iconURL: interaction.user.avatarURL() }) .setDescription( @@ -103,7 +105,9 @@ module.exports = { embeds: [ new EmbedBuilder() .setAuthor({ - name: interaction.member.nickname || interaction.user.username, + name: + interaction.member.nickname || + interaction.user.username, iconURL: interaction.user.avatarURL() }) .setDescription( From 8a15400bbc49064367d7abe47cdbc0b01f45f57f Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sun, 16 Jul 2023 01:45:23 +0200 Subject: [PATCH 11/16] fix: remove period after url when skipping during /nowplaying --- commands/nowplaying.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/nowplaying.js b/commands/nowplaying.js index 82486eb..b6125d7 100644 --- a/commands/nowplaying.js +++ b/commands/nowplaying.js @@ -213,7 +213,7 @@ module.exports = { iconURL: interaction.user.avatarURL() }) .setDescription( - `**${embedIcons.skipped} Skipped track**\n${durationFormat} **[${skippedTrack.title}](${skippedTrack.url})**.` + `**${embedIcons.skipped} Skipped track**\n${durationFormat} **[${skippedTrack.title}](${skippedTrack.url})**` ) .setThumbnail(skippedTrack.thumbnail) .setColor(embedColors.colorSuccess) From d873adacba8a54489a49419c8ae5418d0938f4c5 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sun, 16 Jul 2023 01:49:42 +0200 Subject: [PATCH 12/16] fix: Update text in help command --- commands/help.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/commands/help.js b/commands/help.js index b7dee3a..bdce938 100644 --- a/commands/help.js +++ b/commands/help.js @@ -13,16 +13,16 @@ module.exports = { new EmbedBuilder() .setDescription( `${embedIcons.rule} **List of commands**\n` + - '- `/play` `query` - Add a track or playlist to the queue by searching or url.\n' + + '- `/play` `query` - Add a track or playlist to the queue by url or search.\n' + '- `/pause` - Pause or resume the current track.\n' + '- `/queue` `[page]` - Show the list of tracks added to the queue.\n' + `- \`/nowplaying\` - ${embedIcons.new} Show information about the track currently playing.\n` + - `- \`/loop\` \`mode\` - ${embedIcons.new} Toggle looping a track or the whole queue.\n` + + `- \`/loop\` \`mode\` - ${embedIcons.beta} Toggle looping a track, the whole queue or autoplay.\n` + `- \`/filters\` - ${embedIcons.beta} Toggle various audio filters during playback.\n` + '- `/volume` `[percentage]` - Show or set the playback volume for tracks.\n' + - '- `/skip` `[trackNumber]` - Skip current or specified track.\n' + - '- `/remove` `trackNumber` - Remove a specific track from the queue.\n' + - '- `/leave` - Clear the track queue and remove the bot from voice channel.\n\n' + + '- `/skip` `[trackNumber]` - Skip to next or specified track.\n' + + '- `/remove` `trackNumber` - Remove specified track from the queue.\n' + + '- `/leave` - Clear the queue and remove the bot from voice channel.\n\n' + `${embedIcons.support} **Support server**\nJoin the support server for help or suggestions: \n**${botInfo.supportServerInviteUrl}**\n\n` + `${embedIcons.bot} **Enjoying ${botInfo.name}?**\nAdd me to another server: \n**[Click me!](${botInfo.botInviteUrl})**` ) From 21e95878f0881a7dbad72f0271f55d7ae92754db Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sun, 16 Jul 2023 02:06:53 +0200 Subject: [PATCH 13/16] fix: Add configurable icon for autoplay action --- config.json.example | 1 + 1 file changed, 1 insertion(+) diff --git a/config.json.example b/config.json.example index 7947425..ebff6f7 100644 --- a/config.json.example +++ b/config.json.example @@ -58,6 +58,7 @@ "loop": "🔁", "loopAction": "🔁", "autoplay": "♾️", + "autoplayAction": "♾️", "looping": "🔁", "autoplaying": "♾️", "skipped": "⏭️", From 34d50a92358c2e25dc4b9d6d1f254a66aa6073ea Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sun, 16 Jul 2023 02:23:20 +0200 Subject: [PATCH 14/16] feat: Added /loop command with support for track, queue or autoplay looping --- commands/loop.js | 156 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 commands/loop.js diff --git a/commands/loop.js b/commands/loop.js new file mode 100644 index 0000000..103253e --- /dev/null +++ b/commands/loop.js @@ -0,0 +1,156 @@ +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { useQueue } = require('discord-player'); +const { EmbedBuilder } = require('discord.js'); +const { embedColors, embedIcons, botInfo } = require('../config.json'); + +module.exports = { + data: new SlashCommandBuilder() + .setName('loop') + .setDescription('Toggle looping a track or the whole queue.') + .setDMPermission(false) + .addStringOption((option) => + option + .setName('mode') + .setDescription('Track number to remove from queue.') + .setRequired(false) + .addChoices( + { name: 'Track', value: '1' }, + { name: 'Queue', value: '2' }, + { name: 'Autoplay', value: '3' }, + { name: 'Disabled', value: '0' } + ) + ), + run: async ({ interaction }) => { + if (!interaction.member.voice.channel) { + return await interaction.editReply({ + embeds: [ + new EmbedBuilder() + .setDescription( + `**${embedIcons.warning} Oops!**\nYou need to be in a voice channel to use this command.` + ) + .setColor(embedColors.colorWarning) + ] + }); + } + + const queue = useQueue(interaction.guild.id); + + if (!queue) { + return await interaction.editReply({ + embeds: [ + new EmbedBuilder() + .setDescription( + `**${embedIcons.warning} Oops!**\nThere are no tracks in the queue and nothing currently playing. First add some tracks with \`/play\`!` + ) + .setColor(embedColors.colorWarning) + ] + }); + } + + const loopModesFormatted = new Map([ + [0, 'disabled'], + [1, 'track'], + [2, 'queue'], + [3, 'autoplay'] + ]); + + const mode = parseInt(interaction.options.getString('mode')); + const modeUserString = loopModesFormatted.get(mode); + const currentMode = queue.repeatMode; + const currentModeUserString = loopModesFormatted.get(currentMode); + + if (!mode && mode !== 0) { + return await interaction.editReply({ + embeds: [ + new EmbedBuilder() + .setDescription( + `**${ + currentMode === 3 + ? embedIcons.autoplay + : embedIcons.loop + } Current loop mode**\nThe looping mode is currently set to \`${currentModeUserString}\`.` + ) + .setColor(embedColors.colorInfo) + ] + }); + } + + if (mode === currentMode) { + return await interaction.editReply({ + embeds: [ + new EmbedBuilder() + .setDescription( + `**${embedIcons.warning} Oops!**\nLoop mode is already \`${modeUserString}\`.` + ) + .setColor(embedColors.colorWarning) + ] + }); + } + + queue.setRepeatMode(mode); + + if (!queue.repeatMode === mode) { + return await interaction.editReply({ + embeds: [ + new EmbedBuilder() + .setDescription( + `**${embedIcons.error} Uh-oh... Failed to change loop mode!**\nI tried to change the loop mode to \`${modeUserString}\`, but something went wrong.\n\nYou can try to perform the command again.\n\n_If you think this message is incorrect or the issue persists, please submit a bug report in the **[support server](${botInfo.supportServerInviteUrl})**._` + ) + .setColor(embedColors.colorError) + ] + }); + } + + if (queue.repeatMode === 0) { + return await interaction.editReply({ + embeds: [ + new EmbedBuilder() + .setAuthor({ + name: + interaction.member.nickname || + interaction.user.username, + iconURL: interaction.user.avatarURL() + }) + .setDescription( + `**${embedIcons.success} Loop mode disabled**\nChanging loop mode from \`${currentModeUserString}\` to \`${modeUserString}\`.\n\nThe ${currentModeUserString} will no longer play on repeat!` + ) + .setColor(embedColors.colorSuccess) + ] + }); + } + + if (queue.repeatMode === 3) { + return await interaction.editReply({ + embeds: [ + new EmbedBuilder() + .setAuthor({ + name: + interaction.member.nickname || + interaction.user.username, + iconURL: interaction.user.avatarURL() + }) + .setDescription( + `**${embedIcons.autoplaying} Loop mode changed**\nChanging loop mode from \`${currentModeUserString}\` to \`${modeUserString}\`.\n\nWhen the queue is empty, similar tracks will start playing!` + ) + .setColor(embedColors.colorSuccess) + ] + }); + } + + return await interaction.editReply({ + embeds: [ + new EmbedBuilder() + .setAuthor({ + name: + interaction.member.nickname || + interaction.user.username, + iconURL: interaction.user.avatarURL() + }) + .setDescription( + `**${embedIcons.looping} Loop mode changed**\nChanging loop mode from \`${currentModeUserString}\` to \`${modeUserString}\`.\n\nThe ${modeUserString} will now play on repeat!` + ) + .setColor(embedColors.colorSuccess) + ] + }); + } +}; From 3b147bd0b05fd714a5477fe6c884dec2980415a0 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sun, 16 Jul 2023 02:23:36 +0200 Subject: [PATCH 15/16] fix: /nowplaying and /queue now indicate looping mode if enabled --- commands/nowplaying.js | 24 ++++++++++++++++++++---- commands/queue.js | 27 ++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/commands/nowplaying.js b/commands/nowplaying.js index b6125d7..fb29bad 100644 --- a/commands/nowplaying.js +++ b/commands/nowplaying.js @@ -109,6 +109,15 @@ module.exports = { .setEmoji(embedIcons.nextTrack) ); + const loopModesFormatted = new Map([ + [0, 'disabled'], + [1, 'track'], + [2, 'queue'], + [3, 'autoplay'] + ]); + + const loopModeUserString = loopModesFormatted.get(queue.repeatMode); + const response = await interaction.editReply({ embeds: [ new EmbedBuilder() @@ -122,11 +131,18 @@ module.exports = { (queue.node.isPaused() ? '**Currently Paused**\n' : `**${embedIcons.audioPlaying} Now Playing**\n`) + - (currentTrack - ? `**[${currentTrack.title}](${currentTrack.url})**` - : 'None') + + `**[${currentTrack.title}](${currentTrack.url})**` + `\nRequested by: <@${currentTrack.requestedBy.id}>` + - `\n ${bar}\n\n` + `\n ${bar}\n\n` + + `${ + queue.repeatMode === 0 + ? '' + : `**${ + queue.repeatMode === 3 + ? embedIcons.autoplay + : embedIcons.loop + } Looping**\nLoop mode is set to ${loopModeUserString}. You can change it with \`/loop\`.` + }` ) .addFields( { diff --git a/commands/queue.js b/commands/queue.js index 3a3d2d7..1179cc9 100644 --- a/commands/queue.js +++ b/commands/queue.js @@ -105,6 +105,25 @@ module.exports = { let currentTrack = queue.currentTrack; + const loopModesFormatted = new Map([ + [0, 'disabled'], + [1, 'track'], + [2, 'queue'], + [3, 'autoplay'] + ]); + + const loopModeUserString = loopModesFormatted.get(queue.repeatMode); + + let repeatModeString = `${ + queue.repeatMode === 0 + ? '' + : `**${ + queue.repeatMode === 3 + ? embedIcons.autoplay + : embedIcons.loop + } Looping**\nLoop mode is set to ${loopModeUserString}. You can change it with \`/loop\`.\n\n` + }`; + if (!currentTrack) { return await interaction.editReply({ embeds: [ @@ -116,7 +135,8 @@ module.exports = { iconURL: interaction.guild.iconURL() }) .setDescription( - `**${embedIcons.queue} Tracks in queue**\n${queueString}` + `${repeatModeString}` + + `**${embedIcons.queue} Tracks in queue**\n${queueString}` ) .setFooter({ text: `Page ${pageIndex + 1} of ${totalPages}` @@ -159,8 +179,9 @@ module.exports = { ? `**[${currentTrack.title}](${currentTrack.url})**` : 'None') + `\nRequested by: <@${currentTrack.requestedBy.id}>` + - `\n ${bar}` + - `\n\n**${embedIcons.queue} Tracks in queue**\n${queueString}` + `\n ${bar}\n\n` + + `${repeatModeString}` + + `**${embedIcons.queue} Tracks in queue**\n${queueString}` ) .setThumbnail(queue.currentTrack.thumbnail) .setFooter({ From 434bc6730f4cfc0a88e678dcd6d283b58e10457e Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sun, 16 Jul 2023 02:33:05 +0200 Subject: [PATCH 16/16] fix: Indicate looping mode in skipping messages if enabled --- commands/nowplaying.js | 15 ++++++++++++++- commands/skip.js | 20 +++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/commands/nowplaying.js b/commands/nowplaying.js index fb29bad..ec60973 100644 --- a/commands/nowplaying.js +++ b/commands/nowplaying.js @@ -219,6 +219,10 @@ module.exports = { : `\`${skippedTrack.duration}\``; queue.node.skip(); + const repeatModeUserString = loopModesFormatted.get( + queue.repeatMode + ); + return await interaction.followUp({ embeds: [ new EmbedBuilder() @@ -229,7 +233,16 @@ module.exports = { iconURL: interaction.user.avatarURL() }) .setDescription( - `**${embedIcons.skipped} Skipped track**\n${durationFormat} **[${skippedTrack.title}](${skippedTrack.url})**` + `**${embedIcons.skipped} Skipped track**\n${durationFormat} **[${skippedTrack.title}](${skippedTrack.url})**` + + `${ + queue.repeatMode === 0 + ? '' + : `\n\n**${ + queue.repeatMode === 3 + ? embedIcons.autoplaying + : embedIcons.looping + } Looping**\nLoop mode is set to ${repeatModeUserString}. You can change it with \`/loop\`.` + }` ) .setThumbnail(skippedTrack.thumbnail) .setColor(embedColors.colorSuccess) diff --git a/commands/skip.js b/commands/skip.js index fff30c1..731835f 100644 --- a/commands/skip.js +++ b/commands/skip.js @@ -101,6 +101,15 @@ module.exports = { : `\`${skippedTrack.duration}\``; queue.node.skip(); + const loopModesFormatted = new Map([ + [0, 'disabled'], + [1, 'track'], + [2, 'queue'], + [3, 'autoplay'] + ]); + + const loopModeUserString = loopModesFormatted.get(queue.repeatMode); + return await interaction.editReply({ embeds: [ new EmbedBuilder() @@ -111,7 +120,16 @@ module.exports = { iconURL: interaction.user.avatarURL() }) .setDescription( - `**${embedIcons.skipped} Skipped track**\n${durationFormat} **[${skippedTrack.title}](${skippedTrack.url})**` + `**${embedIcons.skipped} Skipped track**\n${durationFormat} **[${skippedTrack.title}](${skippedTrack.url})**` + + `${ + queue.repeatMode === 0 + ? '' + : `\n\n**${ + queue.repeatMode === 3 + ? embedIcons.autoplaying + : embedIcons.looping + } Looping**\nLoop mode is set to ${loopModeUserString}. You can change it with \`/loop\`.` + }` ) .setThumbnail(skippedTrack.thumbnail) .setColor(embedColors.colorSuccess)