I'm currently working on a music bot that I want to automatically leave after a certain amount of time, unless 24/7 mode is enabled and the queue ends. The problem I'm facing is that when new audio starts playing, the bot still leaves after the set time.
.on ("queueEnd", (player) => setTimeout(() => {
// Don't leave if 24/7 mode is active
let QueueEmbed = new MessageEmbed()
.setAuthor("The queue has ended", this.botconfig.IconURL)
.setColor(this.botconfig.EmbedColor)
.setTimestamp();
client.channels.cache.get(player.textChannel).send( { embeds: [ QueueEmbed ] } );
if (!this.config["24/7"]) player.destroy();
}, 30000));
If 24/7 mode is set to false, the bot remains for the specified time. However, I need it to cancel the destroy action if new audio starts playing again, and I'm struggling to figure out how to achieve that.