From 40490d80dc9629a7d9bc4c2250a04827e691dc63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Wed, 4 Aug 2021 17:46:06 +0300 Subject: [PATCH] Updated stop.js & voiceStateUpdate.js --- src/client/commands/stop.js | 4 ++-- src/client/events/voiceStateUpdate.js | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/client/commands/stop.js b/src/client/commands/stop.js index 52628b5..e3de6e5 100644 --- a/src/client/commands/stop.js +++ b/src/client/commands/stop.js @@ -9,8 +9,8 @@ module.exports = { const radio = client.radio.get(msg.guild.id); if (client.funcs.check(client, msg, command)) { client.funcs.statisticsUpdate(client, msg.guild, radio); - radio.connection.destroy(); - radio.audioPlayer.stop(); + radio.connection?.destroy(); + radio.audioPlayer?.stop(); client.radio.delete(msg.guild.id); msg.channel.send(client.messageEmojis["stop"] + client.messages.stop); } diff --git a/src/client/events/voiceStateUpdate.js b/src/client/events/voiceStateUpdate.js index e32bbb6..553717e 100644 --- a/src/client/events/voiceStateUpdate.js +++ b/src/client/events/voiceStateUpdate.js @@ -16,8 +16,8 @@ module.exports = { if (newState.channel === null) { client.funcs.statisticsUpdate(client, newState.guild, radio); - radio.connection.destroy(); - radio.audioPlayer.stop(); + radio.connection?.destroy(); + radio.audioPlayer?.stop(); return client.radio.delete(newState.guild.id); } @@ -37,8 +37,8 @@ module.exports = { ); } catch (error) { client.funcs.statisticsUpdate(client, newState.guild, radio); - radio.connection.destroy(); - radio.audioPlayer.stop(); + radio.connection?.destroy(); + radio.audioPlayer?.stop(); client.radio.delete(oldState.guild.id); } return; @@ -52,11 +52,11 @@ module.exports = { } if ((oldState.channel.members.size === 1 && oldState.channel === radio.voiceChannel) || change) { setTimeout(() => { - if (!radio || !radio.connection.dispatcher || !radio.connection.dispatcher === null) return; + if (!radio || !radio.connection || !radio.connection === null) return; if (radio.voiceChannel.members.size === 1) { client.funcs.statisticsUpdate(client, newState.guild, radio); - radio.connection.destroy(); - radio.audioPlayer.stop(); + radio.connection?.destroy(); + radio.audioPlayer?.stop(); client.radio.delete(newState.guild.id); } }, 120000);