Tried to make voice listener in a VC and it didn't log anything

const { AudioReceiveStream, joinVoiceChannel, EndBehaviorType, VoiceReceiver } = require('@discordjs/voice');
const { EmbedBuilder } = require('discord.js');
const axios = require("axios").default;
const fs = require("fs");
/**
*
* @param {import("discord.js").CommandInteraction} context
*/
module.exports = async (context) => {
const {member, client, guild} = context;
const targetChannel = member.voice.channel;

// VC connection verification conditions goes here

const reply = await context.followUp("Starting...");
const connection = joinVoiceChannel({
channelId: targetChannel.id,
guildId: guild.id,
adapterCreator: guild.voiceAdapterCreator,
selfDeaf: false
});
const listener = new AudioReceiveStream({end: EndBehaviorType.AfterSilence});

const writeStream = fs.createWriteStream('user_audio.pcm');
listener.pipe(writeStream);

listener.on('end', async () => {
const audioData = fs.readFileSync('user_audio.pcm');

// play with the voice a lil bit here
});
}
const { AudioReceiveStream, joinVoiceChannel, EndBehaviorType, VoiceReceiver } = require('@discordjs/voice');
const { EmbedBuilder } = require('discord.js');
const axios = require("axios").default;
const fs = require("fs");
/**
*
* @param {import("discord.js").CommandInteraction} context
*/
module.exports = async (context) => {
const {member, client, guild} = context;
const targetChannel = member.voice.channel;

// VC connection verification conditions goes here

const reply = await context.followUp("Starting...");
const connection = joinVoiceChannel({
channelId: targetChannel.id,
guildId: guild.id,
adapterCreator: guild.voiceAdapterCreator,
selfDeaf: false
});
const listener = new AudioReceiveStream({end: EndBehaviorType.AfterSilence});

const writeStream = fs.createWriteStream('user_audio.pcm');
listener.pipe(writeStream);

listener.on('end', async () => {
const audioData = fs.readFileSync('user_audio.pcm');

// play with the voice a lil bit here
});
}
I tried to do this to log a member speaking in the vc but it doesn't do any action after bot joins the channel :p
1 Reply
d.js toolkit
d.js toolkit12mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Want results from more Discord servers?
Add your server