1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-09-20 14:01:55 +00:00
musix-oss/events/voiceStateUpdate.js

21 lines
841 B
JavaScript
Raw Normal View History

2020-02-05 20:02:53 +00:00
module.exports = {
name: 'voiceStateUpdate',
2020-03-04 20:29:12 +00:00
async execute(client, oldState, newState) {
const serverQueue = client.queue.get(newState.guild.id);
2020-02-05 20:02:53 +00:00
if (!serverQueue) return;
2020-03-04 20:29:12 +00:00
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;
2020-02-05 20:02:53 +00:00
}
}
}
}