Skip to content

Commit

Permalink
[Enhancement] various fixes for the music commands
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Nov 23, 2021
1 parent 4e19fe3 commit 4a46129
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 65 deletions.
4 changes: 2 additions & 2 deletions commands/Music/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = {
},
};

await message.channel.send({ embeds: [queueEmbed] });
return await message.channel.send({ embeds: [queueEmbed] });
},
data: new SlashCommandBuilder()
.setName("queue")
Expand Down Expand Up @@ -70,6 +70,6 @@ module.exports = {
},
};

await interaction.followUp({ embeds: [queueEmbed] });
return await interaction.followUp({ embeds: [queueEmbed] });
},
};
4 changes: 4 additions & 0 deletions commands/Music/repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ module.exports = {
],
});
break;

case "1":
await queue.setRepeatMode(Number(mode));
await interaction.followUp({
Expand All @@ -160,6 +161,7 @@ module.exports = {
});

break;

case "2":
await queue.setRepeatMode(Number(mode));
await interaction.followUp({
Expand All @@ -172,13 +174,15 @@ module.exports = {
});

break;

case "3":
await queue.setRepeatMode(Number(mode));
await interaction.followUp({
embeds: [
embedMessage("#9dcc37", `✅ | Autoplay mode has been enabled `),
],
});

break;
}
},
Expand Down
52 changes: 24 additions & 28 deletions commands/Music/resume.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,20 @@ module.exports = {
}

try {
if (queue) {
await queue.setPaused(false);
await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`✅ **${
queue.current.title
}** resumed [${message.member.toString()}]`
),
],
});
}
await queue.setPaused(false);
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`✅ **${
queue.current.title
}** resumed [${message.member.toString()}]`
),
],
});
} catch (err) {
client.logger(err.message, "error");
await message.channel.send({
return await message.channel.send({
embeds: [embedMessage("RED", "❌ I was not able to resume this song")],
});
}
Expand Down Expand Up @@ -119,22 +117,20 @@ module.exports = {
}

try {
if (queue) {
await queue.setPaused(false);
await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`✅ **${
queue.current.title
}** resumed [${interaction.member.toString()}]`
),
],
});
}
await queue.setPaused(false);
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`✅ **${
queue.current.title
}** resumed [${interaction.member.toString()}]`
),
],
});
} catch (err) {
client.logger(err.message, "error");
await interaction.followUp({
return await interaction.followUp({
embeds: [embedMessage("RED", "❌ I was not able to resume this song")],
});
}
Expand Down
11 changes: 6 additions & 5 deletions commands/Music/seek.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
embeds: [
embedMessage(
"RED",
`❌ | Please give how many seconds you wish to seek!`
`❌ | Please provide how many seconds you wish to seek!`
),
],
});
Expand All @@ -34,10 +34,10 @@ module.exports = {
time / 1000
} seconds! [${message.member.toString()}]`,
};
await message.channel.send({ embeds: [embed] });
return await message.channel.send({ embeds: [embed] });
} catch (err) {
client.logger(err.message, "error");
await message.channel.send({
return await message.channel.send({
embeds: [embedMessage("RED", `❌ Could not seek the song!`)],
});
}
Expand All @@ -49,9 +49,10 @@ module.exports = {
option.setName("sec").setDescription("Enter time in seconds")
),
async execute(interaction, client) {
await interaction.deferReply();

const queue = client.player.getQueue(interaction.guild);
const seekNumber = interaction.options.getInteger("sec") * 1000;
await interaction.deferReply();

if (!queue || !queue.playing)
return await interaction.followUp(
Expand All @@ -66,7 +67,7 @@ module.exports = {
seekNumber / 1000
} seconds! [${interaction.member.toString()}]`,
};
await interaction.followUp({ embeds: [embed] });
return await interaction.followUp({ embeds: [embed] });
} catch (error) {
console.error(error);
}
Expand Down
42 changes: 19 additions & 23 deletions commands/Music/shuffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ module.exports = {
});

try {
if (queue) {
await queue.shuffle();
await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`✅ Queue has been shuffled [${message.member.toString()}]`
),
],
});
}
await queue.shuffle();
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`✅ Queue has been shuffled [${message.member.toString()}]`
),
],
});
} catch (error) {
client.logger(error.message, "error");
await message.channel.send({
Expand All @@ -47,20 +45,18 @@ module.exports = {
});

try {
if (queue) {
await queue.shuffle();
await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`✅ Queue has been shuffled [${interaction.member.toString()}]`
),
],
});
}
await queue.shuffle();
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`✅ Queue has been shuffled [${interaction.member.toString()}]`
),
],
});
} catch (error) {
client.logger(error.message, "error");
await interaction.followUp({
return await interaction.followUp({
embeds: [embedMessage("RED", "❌ Could not shuffle the queue")],
});
}
Expand Down
17 changes: 10 additions & 7 deletions commands/Music/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ module.exports = {
}
try {
if (queue && queue.playing) {
await message.channel.send({
let title = queue.current.title;
await queue.stop();
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`✅ Stopped **${queue.current.title}** in [${message.member.voice.channel}]`
`✅ Stopped **${title}** in [${message.member.voice.channel}]`
),
],
});
await queue.stop();
}
} catch (err) {
client.logger(err.message, "error");
Expand Down Expand Up @@ -123,19 +124,21 @@ module.exports = {

try {
if (queue && queue.playing) {
await interaction.followUp({
let title = queue.current.title;
await queue.stop();

return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`✅ Stopped **${queue.current.title}** in [${interaction.member.voice.channel}]`
`✅ Stopped **${title}** in [${interaction.member.voice.channel}]`
),
],
});
await queue.stop();
}
} catch (err) {
client.logger(err.message, "error");
await interaction.followUp({
return await interaction.followUp({
embeds: [embedMessage("RED", `❌ | Something went wrong :/`)],
});
}
Expand Down

0 comments on commit 4a46129

Please sign in to comment.