Update voiceStateUpdate.js

This commit is contained in:
MatteZ02 2020-03-12 01:22:53 +02:00
parent f1184c6e0d
commit 035173b6cc

View File

@ -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(() => {