首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >没有视频标识找到ytdl

没有视频标识找到ytdl
EN

Stack Overflow用户
提问于 2022-04-19 09:29:01
回答 1查看 132关注 0票数 1

你好,最近我开发了一个不和谐的音乐机器人,我让它完美地加入和离开,但播放音乐只是烦人和一些原因,播放和playStream不工作。有了机器人,我想让一个人留言一首歌的名字,它会得到一个网址,但每次都是说没有视频标识,这里找到的是我的代码;

代码语言:javascript
复制
client.on("message", (message) => {
  if (message.content.startsWith(">p")){
let string = message.content;
let lastWord = string.slice(2);

    if (lastWord != ">p"){
          const {joinVoiceChannel} = require('@discordjs/voice')
    const voice = require('@discordjs/voice')
  
const connection = joinVoiceChannel({
    channelId: message.member.voice.channel.id,
    guildId: message.member.guild.id,
    adapterCreator: message.member.guild.voiceAdapterCreator
})
const stream = ytdl(lastWord, {filter: 'audioonly', quality: 'highestaudio'})


         stream.pipe(fs.createWriteStream('tmp_buf_audio.mp3')).on('end', () => {

        connection.playStream(fs.createReadStream('tmp_buf_audio.mp3'))
    }
          )};
 
  }
});

这也是我所犯的错误;

代码语言:javascript
复制
/home/runner/Bot-Project/node_modules/ytdl-core/lib/url-utils.js:63
    throw Error(`No video id found: ${str}`);
          ^

Error: No video id found:  
    at Object.exports.getVideoID (/home/runner/Bot-Project/node_modules/ytdl-core/lib/url-utils.js:63:11)
    at Function.exports.<computed> [as getInfo] (/home/runner/Bot-Project/node_modules/ytdl-core/lib/info.js:484:29)
    at ytdl (/home/runner/Bot-Project/node_modules/ytdl-core/lib/index.js:19:8)
    at Client.<anonymous> (/home/runner/Bot-Project/index.js:83:16)
    at Client.emit (node:events:402:35)
    at Client.emit (node:domain:475:12)
Hint: hit control+c anytime to enter REPL.
Project is running!
(node:7809) DeprecationWarning: The message event is deprecated. Use messageCreate instead
(Use `node --trace-deprecation ...` to show where the warning was created)
Hint: hit control+c anytime to enter REPL.
Project is running!
(node:7923) DeprecationWarning: The message event is deprecated. Use messageCreate instead
(Use `node --trace-deprecation ...` to show where the warning was created)
/home/runner/Bot-Project/node_modules/ytdl-core/lib/url-utils.js:63
    throw Error(`No video id found: ${str}`);
          ^

Error: No video id found:  let it go
    at Object.exports.getVideoID (/home/runner/Bot-Project/node_modules/ytdl-core/lib/url-utils.js:63:11)
    at Function.exports.<computed> [as getInfo] (/home/runner/Bot-Project/node_modules/ytdl-core/lib/info.js:484:29)
    at ytdl (/home/runner/Bot-Project/node_modules/ytdl-core/lib/index.js:19:8)
    at Client.<anonymous> (/home/runner/Bot-Project/index.js:83:16)
    at Client.emit (node:events:402:35)
    at Client.emit (node:domain:475:12)
    at MessageCreateAction.handle (/home/runner/Bot-Project/node_modules/discord.js/src/client/actions/MessageCreate.js:34:18)
    at Object.module.exports [as MESSAGE_CREATE] (/home/runner/Bot-Project/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/home/runner/Bot-Project/node_modules/discord.js/src/client/websocket/WebSocketManager.js:351:31)
Emitted 'error' event on PassThrough instance at:

repl process died unexpectedly: exit status 1
 
EN

回答 1

Stack Overflow用户

发布于 2022-04-22 06:11:50

我看你用的是节点-ytdl-核心。

ytdl(‘.’)的用法是错误的,应改为如下: ytdl(url,options)。

通过https://www.npmjs.com/package/ytdl-core

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71922644

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档