-
-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"leaveOnEmpty" and "channelEmpty" not working #912
Comments
I have the same problem. |
Same problem here. Passing parameter to the queue, not the player. Also, did leaveOnEndCooldown just stopped working? |
These options must be passed in the crequeQueue() method (refers to https://discord-player.js.org/docs/main/master/class/Player?scrollTo=createQueue)
The option is leaveOnEmptyCooldown not leaveOnEndCooldown, but it doesn't work for me as well |
You need to create leaveOnEndCooldown handler by yourself, Maybe take a look of this code. endTimeout.js module.exports = class EndTimeout {
constructor() {
this.timeouts = new Map();
}
setTimeout(queue) {
let timeout = setTimeout(async () => {
queue.connection.disconnect();
queue.destroy(true);
await queue.metadata.send({embeds: [new MessageEmbed()
.setColor('#ffff66')
.setDescription('เนื่องจากไม่มีความเคลื่อนไหว บอทจึงออกจากห้อง')]
});
}, leave_on_end * 1000);
this.timeouts.set(queue.guild.id, timeout);
}
clearTimeout(queue) {
let timeout = this.timeouts.get(queue.guild.id);
if (timeout) {
clearTimeout(timeout);
this.timeouts.delete(queue.guild.id);
}
}
} player-handler.js player
.on('trackAdd', (queue, track) => {
endTimeout.clearTimeout(queue);
})
.on('tracksAdd', (queue, track) => {
endTimeout.clearTimeout(queue);
})
.on('channelEmpty', (queue => {
endTimeout.clearTimeout(queue);
}))
.on('queueEnd', (queue => {
endTimeout.setTimeout(queue);
}))
.on('botDisconnect', (queue => {
endTimeout.clearTimeout(queue);
}))
; Hope this will work for you. |
# #986 |
Describe the bug
When creating the queue with the option "leaveOnEmpty", nothing happens when everyone leaves the channel. Also the "channelEmpty" event is never emitted.
To Reproduce
When creating the queue add the option "leaveOnEmpty" to "true". Exit the channel and the bot will keep playing.
In the events, add the event "channelEmpty". When everyone leaves the channel, nothing will be emitted.
Expected behavior
In the "leaveOnEmpty", the bot should disconnect when everyone leaves.
In the "channelEmpty" event, when everyone leaves the channel, the event should be emitted.
Screenshots/Codes
const queue = await player.createQueue(message.guild, { metadata: message.channel, autoSelfDeaf: true, leaveOnEnd: false, leaveOnStop: true, leaveOnEmpty: true, ytdlOptions: { quality: "highest", filter: "audioonly", highWaterMark: 1 << 25, dlChunkSize: 0, }, });
player.on("channelEmpty", async (queue) => {console.log("Example")}
Please complete the following information:
Additional context
The text was updated successfully, but these errors were encountered: