我想让我的 discord.js 机器人使用 ytdl-core 播放来自 youtube.com 的整个播放列表。我的代码可以播放一首歌曲并一首添加,但我喜欢简单地添加一个播放列表。这是我的代码的一部分:
if (query.includes("www.youtube.com")) {
try {
const ytdata = await yt.getBasicInfo(query);
if (!ytdata) return errorReply("URL song not found");
song = {
name: Util.escapeMarkdown(ytdata.videoDetails.title),
thumbnail:
ytdata.player_response.videoDetails.thumbnail.thumbnails[0].url,
requested: message.author,
videoId: ytdata.videoDetails.videoId,
duration: forHumans(ytdata.videoDetails.lengthSeconds),
url: ytdata.videoDetails.video_url,
views: ytdata.videoDetails.viewCount,
};
} catch (e) {
console.log(e);
return error("Error.");
}
}