From c04714710d92cf073c5da8c21d289b0bceda0f0e Mon Sep 17 00:00:00 2001 From: neptalu0 <43881378+neptalu0@users.noreply.github.com> Date: Sat, 6 May 2023 13:30:27 +0800 Subject: [PATCH 1/5] Update loop.js added new option autoplay --- src/commands/loop.js | 93 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/src/commands/loop.js b/src/commands/loop.js index 41e29d5..2062a1a 100644 --- a/src/commands/loop.js +++ b/src/commands/loop.js @@ -82,3 +82,96 @@ module.exports = { return interaction.reply({ content: `Set loop to \`${names[interaction.options.getString("mode")]}\``, allowedMentions: { repliedUser: false } }); }, }; +module.exports = { + name: 'loop', + aliases: ['lp'], + description: 'Turns the music loop mode on or off', + usage: 'loop ', + voiceChannel: true, + options: [ + { + name: "mode", + description: "The loop mode", + type: 3, + required: true, + choices: [ + { + name: "Off", + value: "off" + }, + { + name: "All", + value: "all" + }, + { + name: "One", + value: "one" + }, + { + name: "Autoplay", + value: "ap" + } + ] + } + ], + + execute(client, message, args) { + const queue = client.player.nodes.get(message.guild.id); + const prefix = client.config.prefix; + + if (!queue || !queue.isPlaying()) + return message.reply({ content: `❌ | There is no music currently playing.`, allowedMentions: { repliedUser: false } }); + + let mode = null; + const methods = ['Off', 'Single', 'All', 'Autoplay']; + + if (!args[0]) + return message.reply({ content: `❌ | ${prefix}loop `, allowedMentions: { repliedUser: false } }); + + switch (args[0].toLowerCase()) { + case 'off': + mode = 0; + break; + case 'one' || 'single': + mode = 1; + break; + case 'all' || 'queue': + mode = 2; + break; + case 'ap' || 'autoplay': + mode = 3; + break; + default: + return message.reply({ content: `❌ | ${prefix}loop `, allowedMentions: { repliedUser: false } }); + } + queue.setRepeatMode(mode); + + message.react('👍'); + return message.reply({ content: `Set loop to \`${methods[mode]}\``, allowedMentions: { repliedUser: false } }); + }, + + slashExecute(client, interaction) { + const queue = client.player.nodes.get(interaction.guild.id); + + if (!queue || !queue.isPlaying()) + return interaction.reply({ content: `❌ | There is no music currently playing.`, allowedMentions: { repliedUser: false } }); + + + const methods = { + off: 0, + one: 1, + all: 2, + ap: 3 + } + const names = { + off: "Off", + one: "Single", + all: "All", + ap: "Autoplay" + } + + queue.setRepeatMode(methods[interaction.options.getString("mode")]); + + return interaction.reply({ content: `Set loop to \`${names[interaction.options.getString("mode")]}\``, allowedMentions: { repliedUser: false } }); + }, +}; From 36b24ef6e302f0dcf6977af691368e4feeb6847f Mon Sep 17 00:00:00 2001 From: neptalu0 <43881378+neptalu0@users.noreply.github.com> Date: Sat, 6 May 2023 13:39:43 +0800 Subject: [PATCH 2/5] Update loop.js --- src/commands/loop.js | 86 +------------------------------------------- 1 file changed, 1 insertion(+), 85 deletions(-) diff --git a/src/commands/loop.js b/src/commands/loop.js index 2062a1a..a98eda4 100644 --- a/src/commands/loop.js +++ b/src/commands/loop.js @@ -1,87 +1,3 @@ -module.exports = { - name: 'loop', - aliases: ['lp'], - description: 'Turns the music loop mode on or off', - usage: 'loop ', - voiceChannel: true, - options: [ - { - name: "mode", - description: "The loop mode", - type: 3, - required: true, - choices: [ - { - name: "Off", - value: "off" - }, - { - name: "All", - value: "all" - }, - { - name: "One", - value: "one" - } - ] - } - ], - - execute(client, message, args) { - const queue = client.player.nodes.get(message.guild.id); - const prefix = client.config.prefix; - - if (!queue || !queue.isPlaying()) - return message.reply({ content: `❌ | There is no music currently playing.`, allowedMentions: { repliedUser: false } }); - - let mode = null; - const methods = ['Off', 'Single', 'All']; - - if (!args[0]) - return message.reply({ content: `❌ | ${prefix}loop `, allowedMentions: { repliedUser: false } }); - - switch (args[0].toLowerCase()) { - case 'off': - mode = 0; - break; - case 'one' || 'single': - mode = 1; - break; - case 'all' || 'queue': - mode = 2; - break; - default: - return message.reply({ content: `❌ | ${prefix}loop `, allowedMentions: { repliedUser: false } }); - } - queue.setRepeatMode(mode); - - message.react('👍'); - return message.reply({ content: `Set loop to \`${methods[mode]}\``, allowedMentions: { repliedUser: false } }); - }, - - slashExecute(client, interaction) { - const queue = client.player.nodes.get(interaction.guild.id); - - if (!queue || !queue.isPlaying()) - return interaction.reply({ content: `❌ | There is no music currently playing.`, allowedMentions: { repliedUser: false } }); - - - const methods = { - off: 0, - one: 1, - all: 2 - } - const names = { - off: "Off", - one: "Single", - all: "All" - } - - queue.setRepeatMode(methods[interaction.options.getString("mode")]); - - return interaction.reply({ content: `Set loop to \`${names[interaction.options.getString("mode")]}\``, allowedMentions: { repliedUser: false } }); - }, -}; module.exports = { name: 'loop', aliases: ['lp'], @@ -174,4 +90,4 @@ module.exports = { return interaction.reply({ content: `Set loop to \`${names[interaction.options.getString("mode")]}\``, allowedMentions: { repliedUser: false } }); }, -}; +}; \ No newline at end of file From f9e94211315d085fe40d23170c45c2c58bd27236 Mon Sep 17 00:00:00 2001 From: neptalu0 <43881378+neptalu0@users.noreply.github.com> Date: Sat, 6 May 2023 13:41:37 +0800 Subject: [PATCH 3/5] Update settings.js to display new loop mode option --- src/utils/player/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/player/settings.js b/src/utils/player/settings.js index 433cc1b..a1c10c9 100644 --- a/src/utils/player/settings.js +++ b/src/utils/player/settings.js @@ -1,5 +1,5 @@ const settings = (queue) => { - const loop = queue.repeatMode ? (queue.repeatMode === 2 ? 'All' : 'Single') : 'Off'; + const loop = queue.repeatMode ? (queue.repeatMode === 2 ? 'All' : (queue.repeatMode === 1 ? 'Single' : (queue.repeatMode === 3 ? 'Autoplay' : 'Off' ))) : 'Off'; const volume = queue.node.volume; const track = queue.currentTrack; const author = track.author; From ea82e7670b336434395b73b15d310ae16dd4ce87 Mon Sep 17 00:00:00 2001 From: neptalu0 <43881378+neptalu0@users.noreply.github.com> Date: Sat, 6 May 2023 13:42:40 +0800 Subject: [PATCH 4/5] Update interactionCreate.js for new loop mode option autoplay --- src/events/interactionCreate.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/events/interactionCreate.js b/src/events/interactionCreate.js index 5121a0b..4e63b61 100644 --- a/src/events/interactionCreate.js +++ b/src/events/interactionCreate.js @@ -82,7 +82,7 @@ module.exports = async (client, int) => { } break; case 'Playing-Loop': { - const methods = ['Off', 'Single', 'All']; + const methods = ['Off', 'Single', 'All', 'Autoplay']; let mode = 0; const select = new StringSelectMenuBuilder() @@ -117,6 +117,9 @@ module.exports = async (client, int) => { case 'All': mode = 2; break; + case 'Autoplay': + mode = 3; + break; } queue.setRepeatMode(mode); From 634717fe6a24e5cad8699e06eec648cf2760d48f Mon Sep 17 00:00:00 2001 From: neptalu0 <43881378+neptalu0@users.noreply.github.com> Date: Sat, 6 May 2023 13:51:14 +0800 Subject: [PATCH 5/5] Update loop.js. forgot to fix display on invalid option --- src/commands/loop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/loop.js b/src/commands/loop.js index a98eda4..08a238d 100644 --- a/src/commands/loop.js +++ b/src/commands/loop.js @@ -58,7 +58,7 @@ module.exports = { mode = 3; break; default: - return message.reply({ content: `❌ | ${prefix}loop `, allowedMentions: { repliedUser: false } }); + return message.reply({ content: `❌ | ${prefix}loop `, allowedMentions: { repliedUser: false } }); } queue.setRepeatMode(mode);