我对createReceiver有问题。我有代码:
client.on('message', message => {
// Voice only works in guilds, if the message does not come from a guild,
// we ignore it
if (!message.guild) return;
if (message.content === '/q') {
// Only try to join the sender's voice channel if they are in one themselves
const voiceChannel = message.member.voiceChannel;
if (message.member.voiceChannel) {
message.member.voiceChannel.join()
.then(connection => { // Connection is an instance of VoiceConnection
connection.on('error', console.error);
// const dispatcher = connection.playFile('C:/Denwer/ddradio/lyubov.mp3');
connection.on('speaking', (user, speaking) => {
if(speaking) {
const receiver = connection.createReceiver();
const stream = receiver.createPCMStream(user);
stream.on('data', chunk => {
console.log(chunk.length);
});
}
});
})
.catch(console.log);
} else {
message.reply('');
}
}
})
console.log(chunk.length);
仅在播放音乐时有效。只有当机器人说话时。他没有听到其他成员的声音。请告诉我问题出在哪里
答案 0 :(得分:0)
我遇到了同样的问题,我不知道如何永远彻底解决它,但是如果您播放一个简短的音频文件(如蜂鸣声),则当漫游器加入频道时,您的代码应该可以工作。