【发布时间】:2021-10-23 22:26:40
【问题描述】:
我正在 discord.js(v12 版本)中创建一个不和谐机器人,我想在其中包含一个音乐命令,但是当我在 中输入指向 YouTube 视频的链接时,它会引发错误:
UnhandledPromiseRejectionWarning:错误:未找到视频 ID:未定义
我想补充一点,当我写一个没有 的链接时,一切正常。
我的代码:
if (message.content.startsWith(`${prefix}play`)) {
const voiceChannel = message.member.voice.channel;
if (!voiceChannel) return message.channel.send("Musisz być na kanale głosowym!");
const permissions = voiceChannel.permissionsFor(message.client.user);
if (!permissions.has(`CONNECT`)) return message.channel.send("Nie mam potrzebnych permisji by wejść na kanał głosowy!");
if (!permissions.has(`SPEAK`)) return message.channel.send("Nie mam potrzebnych permisji by wejść na kanał głosowy!");
const songInfo = await ytdl.getInfo(args[1]);
const song = {
title: songInfo.videoDetails.title,
url: songInfo.videoDetails.video_url,
};
}
【问题讨论】:
标签: javascript node.js discord discord.js bots