使用“播放”命令时音频无法运行

时间:2018-06-20 12:41:22

标签: javascript node.js audio discord.js

我启动了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);

代码的工作方式如下:

  • 我写“ -Play”时,我的机器人已连接到语音通道
  • 什么都没发生...我没有音乐在播放

此外,它给了我这个错误(我认为它可能来自 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)

有人知道我该如何解决吗?

0 个答案:

没有答案