2017-11-20 6 views
0

Discordボットのコマンドの1つは、現在のユーザーの音声チャネルで定義済みの音楽クリップを再生することです。ボットは接続することができますが、曲を演奏するのではなく、即座に去ります。私はconnection.playStreamconnection.playFileの両方を使用しようとしましたが、両方とも同じ(不足している)出力を返すようです。私は何らかの依存関係を見逃しているのですか、または私のコードがちょうど正しく書かれていませんか?どんな助けでも大歓迎です!Discord.jsとytdlの不明な点は、オーディオの再生を完全にスキップします。

const Discord = require('discord.js'); 
const ytdl = require('ytdl-core'); 
const client = new Discord.Client(); 
const streamOptions = { seek: 0, volume: 1}; 

client.on('ready',() => { 
    console.log('Login Success'); 
}); 

client.on('message', message => { 
    if (message.content === '$vaporwave') { 
    if (!message.guild) return; 
    if(message.member.voiceChannel) { 
     message.member.voiceChannel.join().then(connection => { 
     console.log("joined channel"); 
     //const stream = ytdl('https://www.youtube.com/watch?v=cU8HrO7XuiE', { filter : 'audioonly' }); 
     const dispatcher = connection.playFile('./mcp420.mp3'); 
     //const dispatcher = connection.playStream(stream, streamOptions); 
     dispatcher.on("end", end => { 
      console.log("left channel"); 
      message.member.voiceChannel.leave(); 
     }); 
     }).catch(err => console.log(err)); 
    } 
    } 
}); 
  • NPMのv4.6.1
  • のNode.js v8.9.1
  • FFMPEG v3.2.8-1、私はsodiumがいなかったことを発見することができたdispatcher.on('error', console.error);を使用することにより

答えて

0

ホストマシンにインストールされていて、ファイルの再生中にエラーが発生しました。正常に動作しています。

関連する問題