From 05f73c3edfe9f856db431f1b3893593ae2dfb0fb Mon Sep 17 00:00:00 2001 From: Schuyler Cebulskie Date: Tue, 25 Oct 2016 20:41:23 -0400 Subject: [PATCH] Clean up voice channel join permissions check --- src/client/voice/ClientVoiceManager.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/client/voice/ClientVoiceManager.js b/src/client/voice/ClientVoiceManager.js index ee088d8e3..eea0dc8a8 100644 --- a/src/client/voice/ClientVoiceManager.js +++ b/src/client/voice/ClientVoiceManager.js @@ -47,19 +47,16 @@ class ClientVoiceManager { */ sendVoiceStateUpdate(channel, options = {}) { if (!this.client.user) throw new Error('Unable to join because there is no client user.'); - - if (channel.permissionsFor) { - const permissions = channel.permissionsFor(this.client.user); - if (permissions) { - if (!permissions.hasPermission('CONNECT')) { - throw new Error('You do not have permission to connect to this voice channel.'); - } - } else { - throw new Error('There is no permission set for the client user in this channel - are they part of the guild?'); - } - } else { + if (!channel.permissionsFor) { throw new Error('Channel does not support permissionsFor; is it really a voice channel?'); } + const permissions = channel.permissionsFor(this.client.user); + if (!permissions) { + throw new Error('There is no permission set for the client user in this channel - are they part of the guild?'); + } + if (!permissions.hasPermission('CONNECT')) { + throw new Error('You do not have permission to connect to this voice channel.'); + } options = mergeDefault({ guild_id: channel.guild.id,