Reputation: 31
Why is this happening???
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}`);
}
Upvotes: 2
Views: 5181
Reputation: 353
The answer is in the error message. You can't use the await
statement inside a function that isn't declared as async
.
Incorrect:
function doSomething() {
var result = await doSomethingElse()
}
Correct:
async function doSomethingAsync() {
var result = await doSomethingElse()
}
More information on async functions here at MDN.
Upvotes: 1