[英]how can I make my bot disconnect from voice after 15 seconds being idle in discord.js
I want to make a music bot, that disconnects after being idle for 15 seconds.我想制作一个音乐机器人,它会在闲置 15 秒后断开连接。
My code:我的代码:
player.on(AudioPlayerStatus.Idle, () => {
message.channel.send('<:Bye:958269757541466145> **Queue finished... Leaving!**')
connection.disconnect();
});
I am using Discord.js v13.8.0 and Node.js 16我正在使用 Discord.js v13.8.0 和 Node.js 16
Use setTimeout function -使用 setTimeout function -
player.on(AudioPlayerStatus.Idle, () => {
setTimeout(() => {
message.channel.send('<:Bye:958269757541466145> **Queue finished... Leaving!**')
connection.disconnect();
}, 15000);
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.