youtube-api-v3-search вместе с discord.js

У меня есть музыкальный дискорд бот, который должен искать видео на ютуб по команде

*add <link or key-words>

*add + ссылка - работает А при попытке искать видео, с помощью youtube-api-v3-search выдает ошибку:

Calling `ytdl.getInfo` with a callback will be removed in a near future release. Use async/await.
/home/adrian/node_modules/ytdl-core/lib/util.js:261
    throw Error(`No video id found: ${link}`);
    ^

Error: No video id found: test
    at Object.exports.getURLVideoID.link [as getURLVideoID] (/home/adrian/node_modules/ytdl-core/lib/util.js:261:11)
    at Object.exports.getVideoID.str [as getVideoID] (/home/adrian/node_modules/ytdl-core/lib/util.js:285:20)
    at Object.exports.(anonymous function) [as getInfo] (/home/adrian/node_modules/ytdl-core/lib/info.js:320:19)
    at Function.exports.(anonymous function) [as getInfo] (/home/adrian/node_modules/ytdl-core/lib/info.js:316:29)
    at Object.add (/home/adrian/Projects/SDC-56-3/bot.js:34:6)
    at Client.client.on.msg (/home/adrian/Projects/SDC-56-3/bot.js:20:177)
    at Client.emit (events.js:198:13)
    at MessageCreateAction.handle (/home/adrian/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (/home/adrian/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/home/adrian/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)

Код:

    'add': (msg) => {
        let url = msg.content.split(' ')[1];
        if (url == '' || url === undefined) return msg.channel.send(`Необходимо добавить ссылку на YouTube видео или ID после ${config.prefix}add`);
        yt.getInfo(url, (err, info) => {
            if (err) {
                // Сообщение после команды *add
                var args = msg.content.slice(config.prefix.length).trim().split(" ");
                args.splice(0, 2);
                var mesg = args.join(" ");
                // Помещаем запрос в параметр для поиска
                var options = {
                    q: mesg,
                    part: 'snippet',
                    type: 'video'
                };
                // Сам поиск
                searchYoutube(config.youtube_api_key, options, function (err, result) {
                    if (err) {
                        console.log(err + " |-------|-------| " + JSON.stringify(info));
                    } else {
                        url = result.items[0].id.videoId;
                        yt.getInfo(url, (err, info) => {
                            if (!err) {
                                if (!queue.hasOwnProperty(msg.guild.id)) queue[msg.guild.id] = {}, queue[msg.guild.id].playing = false, queue[msg.guild.id].songs = [];
                                queue[msg.guild.id].songs.push({url: url, title: info.title, requester: msg.author.username});
                                msg.channel.send("Добавлено в очередь: ```"+info.title+"```");
                            }
                        });
                    }
                });
            } else {
                if (!queue.hasOwnProperty(msg.guild.id)) queue[msg.guild.id] = {}, queue[msg.guild.id].playing = false, queue[msg.guild.id].songs = [];
                queue[msg.guild.id].songs.push({url: url, title: info.title, requester: msg.author.username});
                msg.channel.send("Добавлено в очередь: ```"+info.title+"```");
            }
        });
    }

Что пошло не так?


Ответы (0 шт):