mirror of
https://github.com/danbulant/discord.js
synced 2026-06-07 08:41:29 +00:00
Clean up voice channel join permissions check
This commit is contained in:
parent
b2a4545c16
commit
05f73c3edf
1 changed files with 8 additions and 11 deletions
|
|
@ -47,19 +47,16 @@ class ClientVoiceManager {
|
||||||
*/
|
*/
|
||||||
sendVoiceStateUpdate(channel, options = {}) {
|
sendVoiceStateUpdate(channel, options = {}) {
|
||||||
if (!this.client.user) throw new Error('Unable to join because there is no client user.');
|
if (!this.client.user) throw new Error('Unable to join because there is no client user.');
|
||||||
|
if (!channel.permissionsFor) {
|
||||||
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 {
|
|
||||||
throw new Error('Channel does not support permissionsFor; is it really a voice channel?');
|
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({
|
options = mergeDefault({
|
||||||
guild_id: channel.guild.id,
|
guild_id: channel.guild.id,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue