Discord.js voiceConnection.receiver和VoiceReceiver.createPCMStream未接收数据
标题是我的问题。以下是我正在使用的代码: const voiceChannel=message.guild.channels.findchannel=>channel.name==args[0]; 如果voiceChannel | | voiceChannel.type!='声音'{ 返回消息。回复`我找不到语音频道${args[0]}。`; } 等待voiceChannel.join; 让连接=message.guild.voiceConnection; 连接。在“讲话”时,用户讲话=>{ 如果说{ const receiver=connection.createReceiver; const stream=receiver.createPCMStreamuser; “opus”上的receiver.on,user,buffer=>{ 日志“得到一些数据”; }; stream.on'data',chunk=>{ console.logchunk.length; }; } }; 控制台中没有打印任何内容,因此我猜流和语音接收器没有接收任何数据。另外,我看过很多帖子,很多人都使用这段代码,它对他们很有用。如果有人知道这是为什么,请帮助!!Discord.js voiceConnection.receiver和VoiceReceiver.createPCMStream未接收数据,discord.js,Discord.js,标题是我的问题。以下是我正在使用的代码: const voiceChannel=message.guild.channels.findchannel=>channel.name==args[0]; 如果voiceChannel | | voiceChannel.type!='声音'{ 返回消息。回复`我找不到语音频道${args[0]}。`; } 等待voiceChannel.join; 让连接=message.guild.voiceConnection; 连接。在“讲话”时,用户讲话=>{ 如
提前谢谢。现在回答有点晚,但可能会帮助其他人 您必须先发送静默帧
const { Readable } = require('stream');
class Silence extends Readable {
_read() {
this.push(Buffer.from([0xF8, 0xFF, 0xFE]));
}
}
与语音频道建立连接后,您可以执行以下操作:
connection.on('ready', ()=>{
connection.play(new Silence(), { type: 'opus' });
})
有关更多详细信息,您可以在此处访问此完全相同的问题。