Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for new loop option autoplay #24

Merged
merged 5 commits into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/commands/loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
name: 'loop',
aliases: ['lp'],
description: 'Turns the music loop mode on or off',
usage: 'loop <all/one/off>',
usage: 'loop <ap/all/one/off>',
voiceChannel: true,
options: [
{
Expand All @@ -22,6 +22,10 @@ module.exports = {
{
name: "One",
value: "one"
},
{
name: "Autoplay",
value: "ap"
}
]
}
Expand All @@ -35,10 +39,10 @@ module.exports = {
return message.reply({ content: `❌ | There is no music currently playing.`, allowedMentions: { repliedUser: false } });

let mode = null;
const methods = ['Off', 'Single', 'All'];
const methods = ['Off', 'Single', 'All', 'Autoplay'];

if (!args[0])
return message.reply({ content: `❌ | ${prefix}loop <all/one/off>`, allowedMentions: { repliedUser: false } });
return message.reply({ content: `❌ | ${prefix}loop <ap/all/one/off>`, allowedMentions: { repliedUser: false } });

switch (args[0].toLowerCase()) {
case 'off':
Expand All @@ -50,8 +54,11 @@ module.exports = {
case 'all' || 'queue':
mode = 2;
break;
case 'ap' || 'autoplay':
mode = 3;
break;
default:
return message.reply({ content: `❌ | ${prefix}loop <all/one/off>`, allowedMentions: { repliedUser: false } });
return message.reply({ content: `❌ | ${prefix}loop <ap/all/one/off>`, allowedMentions: { repliedUser: false } });
}
queue.setRepeatMode(mode);

Expand All @@ -69,16 +76,18 @@ module.exports = {
const methods = {
off: 0,
one: 1,
all: 2
all: 2,
ap: 3
}
const names = {
off: "Off",
one: "Single",
all: "All"
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 } });
},
};
};
5 changes: 4 additions & 1 deletion src/events/interactionCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -117,6 +117,9 @@ module.exports = async (client, int) => {
case 'All':
mode = 2;
break;
case 'Autoplay':
mode = 3;
break;
}
queue.setRepeatMode(mode);

Expand Down
2 changes: 1 addition & 1 deletion src/utils/player/settings.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down