0
Discordボットのコマンドの1つは、現在のユーザーの音声チャネルで定義済みの音楽クリップを再生することです。ボットは接続することができますが、曲を演奏するのではなく、即座に去ります。私はconnection.playStream
とconnection.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);
を使用することにより