module.exports = { name: 'voiceStateUpdate', async execute(client, oldState, newState) { let change = false; const queue = client.queue.get(newState.guild.id); if (!queue) return; if (newState.member.id === client.user.id && oldState.member.id === client.user.id) { if (newState.member.voice.channel === null) { queue.songs = []; queue.looping = false; queue.endReason = "manual disconnect"; return client.queue.delete(newState.guild.id); } if (newState.member.voice.channel !== queue.voiceChannel) { change = true; queue.voiceChannel = newState.member.voice.channel; queue.connection = newState.connection; } } if (oldState.channel === null) return; if (oldState.channel.members.size === 1 && oldState.channel === queue.voiceChannel || change) { setTimeout(() => { if (!queue) return; if (queue.voiceChannel.members.size === 1) { queue.songs = []; queue.looping = false; queue.endReason = "Timeout"; queue.connection.dispatcher.end(); } }, 12000); } } }