【发布时间】:2021-06-15 16:43:00
【问题描述】:
我最近使用 discord.js 制作了一个不和谐机器人。我创建的机器人加入了 VC 并播放音乐。有时,当机器人尝试加入 VC 时,我的终端会崩溃。如何阻止这种情况发生并使其继续使用代码。
这是我到目前为止所得到的。
client.on('message', async message => {
if (message.member.voice.channel) {
const connection = await message.member.voice.channel.join();
connection.play(ytdl('https://www.youtube.com/watch?v=jRxSRyrTANY', { quality: 'highestaudio' },{ type: 'opus' }));
setTimeout(() => {
connection.disconnect();
}, 12000);
if (console.log.error);
}
});
另外,这个网站 (https://discordjs.guide/voice/optimisation-and-troubleshooting.html#preparing-your-bot-for-debugging) 建议这样做
client.on('debug', console.log);
channel.join().then(connection => {
connection.on('debug', console.log);
});
但我不知道把它放在代码的什么地方? 我该怎么办?
【问题讨论】:
-
bot 崩溃时出现什么错误?
标签: debugging discord discord.js bots voice