【发布时间】:2021-06-15 22:03:47
【问题描述】:
我正在尝试为不和谐做一个音乐机器人,我为此遵循了一个教程。 但是,当我运行时显示此错误“SyntaxError:等待仅在异步函数中有效” 这是代码:
const songInfo = await ytdl.getInfo(args[1]);
const song = {
title: songInfo.videoDetails.title,
url: songInfo.voiceDetails.video_url,
};
我不明白我必须改变什么才能工作。
【问题讨论】:
-
错误提示“SyntaxError: await is only valid in async function”。因此,当您执行
await ytdl.getInfo(args[1])时,它可能在异步函数之外。你能包括代码所在的完整功能吗?
标签: javascript discord.js