From 202743e63be5e0a5861724b1a0e11be145f16b5e Mon Sep 17 00:00:00 2001 From: MatteZ02 <47610069+MatteZ02@users.noreply.github.com> Date: Sat, 23 Nov 2019 09:17:43 +0200 Subject: [PATCH] patched the error if skipping when nothing is playing --- commands/loop.js | 1 + commands/nowplaying.js | 1 + commands/pause.js | 1 + commands/queue.js | 1 + commands/remove.js | 1 + commands/resume.js | 1 + commands/seek.js | 1 + commands/skip.js | 1 + commands/stop.js | 3 ++- commands/volume.js | 1 + 10 files changed, 11 insertions(+), 1 deletion(-) 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]);