1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-22 21:13:18 +00:00

Update voiceStateUpdate.js

This commit is contained in:
MatteZ02 2020-03-04 22:29:12 +02:00
parent 6bf3ffdfc9
commit 1813f6b03f

View File

@ -1,12 +1,19 @@
module.exports = {
name: 'voiceStateUpdate',
async execute(client, newMember) {
const serverQueue = client.queue.get(newMember.guild.id);
async execute(client, oldState, newState) {
const serverQueue = client.queue.get(newState.guild.id);
if (!serverQueue) return;
if (newMember === client.user) {
if (newMember.voice.channel !== serverQueue.voiceChannel) {
serverQueue.voiceChannel = newMember.voice.channel;
console.log(`Changed serverQueue voiceChannel since Musix was moved to a different channel!`);
if (newState.member.id === client.user.id && oldState.member.id === client.user.id) {
if (newState.member.voice.channel === null) {
serverQueue.songs = [];
serverQueue.looping = false;
serverQueue.endReason = "manual disconnect";
return client.queue.delete(newState.guild.id);
}
if (newState.member.voice.channel !== serverQueue.voiceChannel) {
serverQueue.voiceChannel = newState.member.voice.channel;
serverQueue.connection = newState.connection;
return;
}
}
}