1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 06:43:17 +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 = { module.exports = {
name: 'voiceStateUpdate', name: 'voiceStateUpdate',
async execute(client, newMember) { async execute(client, oldState, newState) {
const serverQueue = client.queue.get(newMember.guild.id); const serverQueue = client.queue.get(newState.guild.id);
if (!serverQueue) return; if (!serverQueue) return;
if (newMember === client.user) { if (newState.member.id === client.user.id && oldState.member.id === client.user.id) {
if (newMember.voice.channel !== serverQueue.voiceChannel) { if (newState.member.voice.channel === null) {
serverQueue.voiceChannel = newMember.voice.channel; serverQueue.songs = [];
console.log(`Changed serverQueue voiceChannel since Musix was moved to a different channel!`); 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;
} }
} }
} }