Skip to content

Commit

Permalink
[Fix] commands can only be used if the message author is in the same …
Browse files Browse the repository at this point in the history
…channel as the bot
  • Loading branch information
naseif committed Nov 4, 2021
1 parent 2176703 commit 91bf51f
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 2 deletions.
27 changes: 27 additions & 0 deletions commands/Music/clear.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ module.exports = {
async run(message, args, client) {
const queue = client.player.getQueue(message.guild);

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 clear the queue!`
),
],
});

if (!queue) {
return await message.channel.send({
embeds: [
Expand Down Expand Up @@ -71,6 +84,20 @@ module.exports = {
await interaction.deferReply();
const queue = client.player.getQueue(interaction.guild);

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 clear the queue!`
),
],
});

if (!queue) {
return await interaction.followUp({
embeds: [
Expand Down
28 changes: 28 additions & 0 deletions commands/Music/jump.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ module.exports = {
async run(message, args, client) {
const queue = client.player.getQueue(message.guild);

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 jump to a new song!`
),
],
});

if (!queue || !queue.playing)
return await message.channel.send({
embeds: [
Expand Down Expand Up @@ -75,6 +88,21 @@ module.exports = {
await interaction.deferReply();
const queue = client.player.getQueue(interaction.guild);
const position = interaction.options.getInteger("position");

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 jump to a new song!`
),
],
});

if (!queue || !queue.playing)
return await interaction.followUp({
embeds: [
Expand Down
27 changes: 27 additions & 0 deletions commands/Music/pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ module.exports = {
async run(message, args, client) {
const queue = client.player.getQueue(message.guild);

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 pause the current song!`
),
],
});

if (!queue || !queue.playing)
return await message.channel.send({
embeds: [
Expand Down Expand Up @@ -63,6 +76,20 @@ module.exports = {
await interaction.deferReply();
const queue = client.player.getQueue(interaction.guild);

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 pause the current song!`
),
],
});

if (!queue || !queue.playing)
return await interaction.followUp({
embeds: [
Expand Down
27 changes: 27 additions & 0 deletions commands/Music/resume.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ module.exports = {
async run(message, args, client) {
const queue = client.player.getQueue(message.guild);

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 resume the current song!`
),
],
});

if (!queue || !queue.playing)
return await message.channel.send({
embeds: [
Expand Down Expand Up @@ -66,6 +79,20 @@ module.exports = {
await interaction.deferReply();
const queue = client.player.getQueue(interaction.guild);

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 resume the current song!`
),
],
});

if (!queue || !queue.playing)
return await interaction.followUp({
embeds: [
Expand Down
14 changes: 14 additions & 0 deletions commands/Music/skip.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ module.exports = {
await interaction.deferReply();
const queue = client.player.getQueue(interaction.guild);

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 skip the current song!`
),
],
});

if (!queue || !queue.playing)
return await interaction.followUp({
embeds: [
Expand Down
27 changes: 27 additions & 0 deletions commands/Music/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ module.exports = {
async run(message, args, client) {
const queue = client.player.getQueue(message.guild);

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 stop the queue!`
),
],
});

if (!queue || !queue.playing) {
return await message.channel.send({
embeds: [
Expand Down Expand Up @@ -63,6 +76,20 @@ module.exports = {
const queue = client.player.getQueue(interaction.guild);
await interaction.deferReply();

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 stop the queue!`
),
],
});

if (!queue || !queue.playing) {
return await interaction.followUp({
embeds: [
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 91bf51f

Please sign in to comment.