我启动了Discord机器人,并尝试从YouTube播放音乐到语音频道:
let args = message.content.split(' ');
// Get the first voice channel
let voiceChannel = message.guild.channels
.filter(function (channel){return channel.type === "voice"})
.first();
console.log(`argument : ${args[1]}`)
// Join the voice channel and play the music
voiceChannel.join().then(connection => {
let stream = YoutubeStream(args[1]);
stream.on('error', function(){
message.channel.send('Can't play your music');
connection.disconnect();
});
connection.playStream(stream);
}).catch(console.error);
代码的工作方式如下:
此外,它给了我这个错误(我认为它可能来自 ffmpeg-binaries ):
events.js:167
throw er; // Unhandled 'error' event
^
TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be one of
type string or Buffer. Received type object
at validChunk (_stream_writable.js:258:10)
at PassThrough.Writable.write (_stream_writable.js:292:21)
at PassThrough.Writable.end (_stream_writable.js:579:10)
at DestroyableTransform.emit (events.js:187:15)
at FfmpegCommand.emit (events.js:182:13)
有人知道我该如何解决吗?