Answer the question
In order to leave comments, you need to log in
Why is PCM file empty when recording voice stream in discord.js?
When entering a command, the bot enters the voice channel and creates a pcm file, but does not write anything to it, who knows what the problem is?
const fs = require("fs");
module.exports.run = async (client, message, args) => {
const voicechannel = message.member.voice.channel;
if (!voicechannel) return message.channel.send("Please join a voice channel first!");
const connection = await message.member.voice.channel.join();
const audio = connection.receiver.createStream(message.member, { mode: 'opus', end: 'silence'});
audio.pipe(fs.createWriteStream(`./recorded-${message.author.id}.pcm`));
audio.on("end", () => {
message.channel.send("Finished writing audio");
});
}
module.exports.help = {
name: "record"
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question