你好,最近我开发了一个不和谐的音乐机器人,我让它完美地加入和离开,但播放音乐只是烦人和一些原因,播放和playStream不工作。有了机器人,我想让一个人留言一首歌的名字,它会得到一个网址,但每次都是说没有视频标识,这里找到的是我的代码;
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'))
}
)};
}
});这也是我所犯的错误;
/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
发布于 2022-04-22 06:11:50
我看你用的是节点-ytdl-核心。
ytdl(‘.’)的用法是错误的,应改为如下: ytdl(url,options)。
https://stackoverflow.com/questions/71922644
复制相似问题