So I’m working on a Discord bot using JS and DiscordJSv14, and want the bot to use audio from a voice chat to send to another bot, some type of listen and snitch bot.
So far I got the Bot’s connecting to the voice call but can’t get any of the packets to send to the other bot.
Here’s some code I’ve got so far:
const connection = joinVoiceChannel({ channelId: C.id, guildId: guild.id, adapterCreator: guild.voiceAdapterCreator, selfDeaf: false, selfMute: false, group: this.client.user.id, }); if (isListener) { console.log("Listener Is Joining Voice And Listening..."); const encoder = new OpusEncoder(48000, 2); let subscription = connection.receiver.subscribe(ID); // ID = Bot's ID // Basically client.user.id subscription.on("data", (chunk) => { console.log(encoder.decode(chunk)); }); }
Console won’t log anything about the chunk Using DiscordJSv14 + @discordjs/opus
Advertisement
Answer
Everything worked fine I just needed to add the following code below.
this.client = new Client({ intents: [GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMessages, GatewayIntentBits.Guilds], });