Skip to content

Commit

Permalink
[Fix] fixed a bug with the disconnect command where users were able t…
Browse files Browse the repository at this point in the history
…o disconnect the bot if not connected to a voice channel
  • Loading branch information
naseif committed Oct 5, 2021
1 parent 4a57192 commit a47a8b7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
21 changes: 21 additions & 0 deletions commands/Music/disconnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ module.exports = {
});
}

if (
message.guild.me.voice.channelId &&
message.member.voice.channelId !== message.guild.me.voice.channelId
)
return await message.channel.send({
embeds: [
embedMessage("#9dcc37", `❌ | You must be in my voice channel to disconnect me!`),
],
});

try {
if (queue) {
await queue.connection.disconnect();
Expand Down Expand Up @@ -58,6 +68,17 @@ module.exports = {
});
}

if (
interaction.guild.me.voice.channelId &&
interaction.member.voice.channelId !== interaction.guild.me.voice.channelId
)
return await interaction.followUp({
embeds: [
embedMessage("#9dcc37", `❌ | You must be in my voice channel to disconnect me!`),
],
});


try {
if (queue) {
await queue.destroy(true);
Expand Down
6 changes: 4 additions & 2 deletions commands/Music/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ module.exports = {
usage: "p <YouTube URL | Song Name | Spotify URL | Soundcloud URL |>",
async run(message, args, client, prefix) {
const songString = args.join(" ");

if (!songString)
return message.channel.send({embeds: [embedMessage("#9dcc37", `❌ | ${message.member.toString()}, You have to provide a song name or URL`)]});
return await message.channel.send({embeds: [embedMessage("#9dcc37", `❌ | ${message.member.toString()}, You have to provide a song name or URL`)]});

if (!message.member.voice.channelId)
return message.channel.send({
embeds: [
Expand All @@ -26,7 +28,7 @@ module.exports = {
message.guild.me.voice.channelId &&
message.member.voice.channelId !== message.guild.me.voice.channelId
)
return message.channel.send({
return await message.channel.send({
embeds: [
embedMessage("#9dcc37", `❌ | You must be in my voice channel!`),
],
Expand Down

0 comments on commit a47a8b7

Please sign in to comment.