在 discord.js 中闲置 15 秒后,如何让我的机器人与语音断开连接

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

我想让机器人在闲置15秒后断开连接,但我不知道怎么做。 我写了一些代码行,但我不知道如何指定时间。我的代码:

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

我正在使用 Discord.js v13 和 Node.js 16

使用setTimeout函数-

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