【发布时间】:2018-11-30 13:18:49
【问题描述】:
我对 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); 仅在播放音乐时工作,那些。只有当机器人说话时。他没有听到其他成员的声音。请告诉我是什么问题
【问题讨论】:
-
他只会在他自己说话的时候发送pcm,但不发送pcm,当其他用户说话时,一边说话一边说话,对用户也有效。
标签: node.js discord.js