为什么会这样?
try {
var connection = await voiceChannel.join();
} catch (error) {
console.error(`I could not join to the voice channel: ${error}`);
return message.channel.send(`I could not join the voice channel: ${error}`);
}
答案 0 :(得分:0)
答案在错误消息中。您不能在未声明为await
的函数中使用async
语句。
不正确:
function doSomething() {
var result = await doSomethingElse()
}
正确:
async function doSomethingAsync() {
var result = await doSomethingElse()
}
有关MDN上的异步功能here的更多信息。