我正在尝试在歌曲结束 1 分钟后检查机器人的队列,然后决定是否离开语音频道(如果为空)还是因为添加了另一首歌曲而留下。每当我使用以下代码时,机器人仍然会在最后一首歌曲完成 30 秒后离开频道,即使添加了另一首歌曲。
.on(
"finish",
(queue) =>
setTimeout(async () => {
if (!client.voice.channel) return clearTimeout();
let musicQueue = await client.distube.getQueue(queue.voiceChannel);
if (musicQueue !== undefined && musicQueue.playing) {
return clearTimeout();
}
if (musicQueue == undefined || musicQueue.songs.length === 0) {
queue.textChannel
.send({
embeds: [
new MessageEmbed()
.setDescription("Finished!")
.setColor("BLACK"),
],
})
.then(() => {
queue.stop(client.voice.channel);
});
}
}, 120000)
);
如果已添加队列,我会尝试将机器人保留在频道中,但我似乎无法让机器人正确检查状态。