'how can I make my bot disconnect from voice after 15 seconds being idle in discord.js

I wanted to make the bot to disconnect after being idle for 15 seconds, but I don't know how. I wrote some code lines but I did not know how to specify a time. My code:

player.on(AudioPlayerStatus.Idle, () => {
                    message.channel.send('<:Bye:958269757541466145> **Queue finished... Leaving!**')
                  connection.disconnect();
                });

I am using Discord.js v13 and Node.js 16



Solution 1:[1]

Use setTimeout function -

  player.on(AudioPlayerStatus.Idle, () => {
    setTimeout(() => {
      message.channel.send('<:Bye:958269757541466145> **Queue finished... Leaving!**')
      connection.disconnect();
    }, 15000);
  })

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1