diff --git a/commands/loop.js b/commands/loop.js index dc180d2c..227d9c03 100644 --- a/commands/loop.js +++ b/commands/loop.js @@ -8,6 +8,7 @@ module.exports = { const serverQueue = client.queue.get(message.guild.id); const permissions = message.channel.permissionsFor(message.author); const { voiceChannel } = message.member; + if (!serverQueue) return message.channel.send(':x: There is nothing playing.'); if (serverQueue.playing) { if (message.author.id !== client.config.dev) { if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to loop the queue!'); diff --git a/commands/nowplaying.js b/commands/nowplaying.js index 0624aea5..f4211876 100644 --- a/commands/nowplaying.js +++ b/commands/nowplaying.js @@ -7,6 +7,7 @@ module.exports = { async execute(message, args, client, Discord, prefix) { const ytdl = require('ytdl-core'); const serverQueue = client.queue.get(message.guild.id); + if (!serverQueue) return message.channel.send(':x: There is nothing playing.'); if (!serverQueue.playing) return message.channel.send(':x: There is nothing playing.'); let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url)); let songtime = (data.length_seconds * 1000).toFixed(0); diff --git a/commands/pause.js b/commands/pause.js index a088b955..03d3510e 100644 --- a/commands/pause.js +++ b/commands/pause.js @@ -8,6 +8,7 @@ module.exports = { const serverQueue = client.queue.get(message.guild.id); const permissions = message.channel.permissionsFor(message.author); const { voiceChannel } = message.member; + if (!serverQueue) return message.channel.send(':x: There is nothing playing.'); if (serverQueue.playing && !serverQueue.paused) { if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to pause the music!'); if (message.author.id !== client.config.dev) { diff --git a/commands/queue.js b/commands/queue.js index 1caf748e..eae25c60 100644 --- a/commands/queue.js +++ b/commands/queue.js @@ -6,6 +6,7 @@ module.exports = { onlyDev: false, async execute(message, args, client, Discord, prefix) { const serverQueue = client.queue.get(message.guild.id); + if (!serverQueue) return message.channel.send(':x: There is nothing playing.'); if (!serverQueue.playing) return message.channel.send(':x: There is nothing playing.'); if (args[1]) { if (isNaN(args[1])) return msg.channel.send(':x: I\'m sorry, But you need to enter a valid __number__.'); diff --git a/commands/remove.js b/commands/remove.js index d03ff450..f25fbf57 100644 --- a/commands/remove.js +++ b/commands/remove.js @@ -8,6 +8,7 @@ module.exports = { const { voiceChannel } = message.member; const serverQueue = client.queue.get(message.guild.id); const permissions = message.channel.permissionsFor(message.author); + if (!serverQueue) return message.channel.send(':x: There is nothing playing.'); if (!serverQueue.playing) return message.channel.send(':x: There is nothing playing'); if (!args[1]) return message.channel.send(':x: Please provide a song position in queue for me to remove!'); const pos = parseInt(args[1]); diff --git a/commands/resume.js b/commands/resume.js index 81fec41b..6e6b5261 100644 --- a/commands/resume.js +++ b/commands/resume.js @@ -8,6 +8,7 @@ module.exports = { const serverQueue = client.queue.get(message.guild.id); const permissions = message.channel.permissionsFor(message.author); const { voiceChannel } = message.member; + if (!serverQueue) return message.channel.send(':x: There is nothing playing.'); if (serverQueue.playing && serverQueue.paused) { if (message.author.id !== client.config.dev) { if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to loop the queue!'); diff --git a/commands/seek.js b/commands/seek.js index 21663d30..090fe17f 100644 --- a/commands/seek.js +++ b/commands/seek.js @@ -9,6 +9,7 @@ module.exports = { const serverQueue = client.queue.get(message.guild.id); const permissions = message.channel.permissionsFor(message.author); const { voiceChannel } = message.member; + if (!serverQueue) return message.channel.send(':x: There is nothing playing.'); let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url)); if (serverQueue.playing) { if (message.author.id !== client.config.devId) { diff --git a/commands/skip.js b/commands/skip.js index 7bff8724..0644bd04 100644 --- a/commands/skip.js +++ b/commands/skip.js @@ -8,6 +8,7 @@ module.exports = { const { voiceChannel } = message.member; const serverQueue = client.queue.get(message.guild.id); const permissions = message.channel.permissionsFor(message.author); + if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could skip for you.'); if (!serverQueue.playing) return message.channel.send(':x: There is nothing playing that I could skip for you.'); if (message.author.id !== client.config.dev) { if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to skip the song!'); diff --git a/commands/stop.js b/commands/stop.js index 38bef9f4..abe1dda7 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -8,8 +8,9 @@ module.exports = { const { voiceChannel } = message.member; const serverQueue = client.queue.get(message.guild.id); const permissions = message.channel.permissionsFor(message.author); + if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could stop for you.'); + if (!serverQueue.playing) return message.channel.send(':x: There is nothing playing that I could stop for you.'); if (message.author.id !== client.config.dev) { - if (!serverQueue.playing) return message.channel.send(':x: There is nothing playing that I could stop for you.'); if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to stop the music!'); if (client.global.db.guilds[message.guild.id].permissions === true) { if (client.global.db.guilds[message.guild.id].dj) { diff --git a/commands/volume.js b/commands/volume.js index 45eb8314..f2cb7f2e 100644 --- a/commands/volume.js +++ b/commands/volume.js @@ -8,6 +8,7 @@ module.exports = { const { voiceChannel } = message.member; const serverQueue = client.queue.get(message.guild.id); const permissions = message.channel.permissionsFor(message.author); + if (!serverQueue) return message.channel.send(':x: There is nothing playing.'); if (!serverQueue.playing) return message.channel.send(':x: There is nothing playing.'); if (!args[1]) return message.channel.send(`:loud_sound: The current volume is: **${serverQueue.volume}**`); const volume = parseFloat(args[1]);