-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Please describe the problem you are having in as much detail as possible:
I have created a simple bot that is supposed to record audio. To do this, I loop through the users in a channel, and create a
read stream for each user. From those read streams, I pipe to a PassThrough so I only have to deal with a single stream at a higher level. The issue that is occurring, is that I am only getting data from any of the streams intermittently. I restart the service 10-15 times, I might get to see data come through once.
Include a reproducible code sample here, if possible:
Here is a demonstration of what I am doing:
const getAllMemberAudioStreams = (voiceChannel: discord.VoiceChannel, conn: discord.VoiceConnection): PassThrough => {
const topLevelStream = new PassThrough();
const members = voiceChannel.members;
members
.filter((user) => user.displayName !== 'AudioClipper')
.forEach((user: discord.GuildMember) => {
//TODO: Need a way to track all of these streams to allow us to end them manually
console.log(`Created read stream for ${user.displayName} -- emitting data for topLevelStream`)
conn.receiver.createStream(user, {
mode: 'opus',
end: 'manual'
})
.pipe(topLevelStream)
.on('error', err => {
console.log(`Got Error: ${JSON.stringify(err)}`);
})
.on('end', () => {
console.log('Stream has ended')
})
});
return topLevelStream;
}Further details:
I haven't been able to see any errors via the .on('error') event. I have tested this with @discordjs/opus and opusscript, installed ffmpeg after I received a bizarre error there. Oddly this works once in a while, I will get data flowing and audio written to a Buffer, then saved to a file. 90% of the time, the bot connects to the voice channel, creates the streams for each user, but nothing comes through.
- discord.js version: ^12.5.1"
- Node.js version: v14.15.1
- Operating system: Ubuntu 20.04.1
- Priority this issue should have – please be realistic and elaborate if possible:
Relevant client options:
- partials: none
- gateway intents: none
- other: none
- [ X ] I have also tested the issue on latest master, commit hash:
c4c817116f868cedb4ec20bcbf90b9b3d382621e