Stop streaming audo after a short time

Hello I have a bot who stream audio in a channel but it work but in a coupe minute it will stop playing for no reason. There no visible erreur on the terminal...
this.on = true ;

// micro
this.arecord = spawn('arecord', ['-D', 'plughw:1', '-f', 'S16_LE', '-r', '48000', '-c', '2']);


this.player = createAudioPlayer();

// flux
this.audioStream = new Readable({
read() {},
});


this.connection = joinVoiceChannel({
channelId: this.message.member.voice.channel.id,
guildId: this.message.guild.id,
adapterCreator: this.message.guild.voiceAdapterCreator,
});

this.audioResource = createAudioResource( this.audioStream, {
inputType: StreamType.Raw,
});


this.player.play( this.audioResource ) ;

this.connection.subscribe( this.player );

// Redirige la sortie de l'enregistrement du microphone vers le tampon
this.arecord.stdout.on('data', (data) => {

this.audioStream.push(data); // Pousse les données dans le flux de lecture

});


this.arecord.on('error', (error) => {
console.error('Erreur lors de la capture de l\'audio du microphone:', error);
});

this.player.on('error', (error) => {
console.error('Erreur lors de la diffusion de l\'audio sur le canal vocal:', error);
});


this.connection_Handler = (oldState, newState) => {

if (newState.status === 'disconnected' && oldState.status !== 'disconnected') {

console.log('Le bot s\'est déconnecté du canal vocal.');

this.stop();

}
};

this.connection.on('stateChange', this.connection_Handler);
this.on = true ;

// micro
this.arecord = spawn('arecord', ['-D', 'plughw:1', '-f', 'S16_LE', '-r', '48000', '-c', '2']);


this.player = createAudioPlayer();

// flux
this.audioStream = new Readable({
read() {},
});


this.connection = joinVoiceChannel({
channelId: this.message.member.voice.channel.id,
guildId: this.message.guild.id,
adapterCreator: this.message.guild.voiceAdapterCreator,
});

this.audioResource = createAudioResource( this.audioStream, {
inputType: StreamType.Raw,
});


this.player.play( this.audioResource ) ;

this.connection.subscribe( this.player );

// Redirige la sortie de l'enregistrement du microphone vers le tampon
this.arecord.stdout.on('data', (data) => {

this.audioStream.push(data); // Pousse les données dans le flux de lecture

});


this.arecord.on('error', (error) => {
console.error('Erreur lors de la capture de l\'audio du microphone:', error);
});

this.player.on('error', (error) => {
console.error('Erreur lors de la diffusion de l\'audio sur le canal vocal:', error);
});


this.connection_Handler = (oldState, newState) => {

if (newState.status === 'disconnected' && oldState.status !== 'disconnected') {

console.log('Le bot s\'est déconnecté du canal vocal.');

this.stop();

}
};

this.connection.on('stateChange', this.connection_Handler);
This not a problem with the micro
1 Reply
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Want results from more Discord servers?
Add your server