From 035173b6cc5bc45380db422c164cad13e615f11c Mon Sep 17 00:00:00 2001 From: MatteZ02 <47610069+MatteZ02@users.noreply.github.com> Date: Thu, 12 Mar 2020 01:22:53 +0200 Subject: [PATCH] Update voiceStateUpdate.js --- events/voiceStateUpdate.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/events/voiceStateUpdate.js b/events/voiceStateUpdate.js index bf07ff0..3eedaab 100644 --- a/events/voiceStateUpdate.js +++ b/events/voiceStateUpdate.js @@ -12,16 +12,11 @@ module.exports = { return client.radio.delete(newState.guild.id); } - if (newState.channel !== radio.voiceChannel) { - change = true; - radio.voiceChannel = newState.channel; - radio.connection = newState.connection; - } const newPermissions = newState.channel.permissionsFor(newState.client.user); if (!newPermissions.has('CONNECT') || !newPermissions.has('SPEAK') || !newPermissions.has('VIEW_CHANNEL')) { try { const connection = await oldState.channel.join(); - radio.connection = connection; + return radio.connection = connection; } catch (error) { radio.songs = []; radio.looping = false; @@ -32,6 +27,11 @@ module.exports = { return msg.channel.send(`<:redx:674263474704220182> An error occured: ${error}`); } } + if (newState.channel !== radio.voiceChannel) { + change = true; + radio.voiceChannel = newState.channel; + radio.connection = newState.connection; + } } if (oldState.channel.members.size === 1 && oldState.channel === radio.voiceChannel || change) { setTimeout(() => {