fix(Player): always emit channelEmpty

This commit is contained in:
DevAndromeda 2021-08-19 16:49:19 +05:45
parent de7de9da43
commit 2fc1089886
No known key found for this signature in database
GPG key ID: FA40E3EC5CB6DCD6

View file

@ -105,7 +105,7 @@ class Player extends EventEmitter<PlayerEvents> {
return void this.emit("botDisconnect", queue);
}
if (!queue.options.leaveOnEmpty || !queue.connection || !queue.connection.channel) return;
if (!queue.connection || !queue.connection.channel) return;
if (!oldState.channelId || newState.channelId) {
const emptyTimeout = queue._cooldownsTimeout.get(`empty_${oldState.guild.id}`);
@ -120,7 +120,7 @@ class Player extends EventEmitter<PlayerEvents> {
const timeout = setTimeout(() => {
if (!Util.isVoiceEmpty(queue.connection.channel)) return;
if (!this.queues.has(queue.guild.id)) return;
queue.destroy();
if (queue.options.leaveOnEmpty) queue.destroy();
this.emit("channelEmpty", queue);
}, queue.options.leaveOnEmptyCooldown || 0).unref();
queue._cooldownsTimeout.set(`empty_${oldState.guild.id}`, timeout);