我在discord.js v12中制作了一个音乐机器人。一切正常,除了我希望漫游器不要只为特定服务器离开语音通道。因此,无论有人是否在VC中,我都希望它始终保持在语音通道中,而只能在特定的服务器中。如果漫游器位于高级服务器中,则它始终保持在VC中。如果不是高级服务器,则如果没有服务器,它将离开VC。我能够实现第二个僵尸程序留在非高级服务器中的情况。但是,在第一种情况下,我无法理解该怎么做,就像我想的那样。这是我的代码:
if (song && queue) {
setTimeout(async function () {
if (message.guild.me.voice.channel) {
if (message.guild.me.voice.channel.members.size == 1 && queue.connection.dispatcher) {
try {
if (collector && !collector.ended) await collector.stop();
await message.client.queue.delete(message.guild.id)
} catch (error) {
console.log(error);
}
queue.channel.leave();
queue.textChannel.send("You left me alone in the voice channel... It hurts my feelings when someone leaves me alone like that :( I left the channel... If you have premium, you can keep me locked in a voice channel, however that's really cruel tho... T_T").catch(console.error);
}
else return;
}
else return;
}, 60000);
}
}
};
我删除了部分代码,因为它太大了。这是上面的主要部分。您能为我提供帮助,让该机器人不再只为特定服务器保留VC吗?预先感谢!