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:
JavaScript
x
22
22
1
const connection = joinVoiceChannel({
2
channelId: C.id,
3
guildId: guild.id,
4
adapterCreator: guild.voiceAdapterCreator,
5
selfDeaf: false,
6
selfMute: false,
7
group: this.client.user.id,
8
});
9
10
if (isListener) {
11
console.log("Listener Is Joining Voice And Listening...");
12
13
const encoder = new OpusEncoder(48000, 2);
14
15
let subscription = connection.receiver.subscribe(ID); // ID = Bot's ID
16
// Basically client.user.id
17
18
subscription.on("data", (chunk) => {
19
console.log(encoder.decode(chunk));
20
});
21
}
22
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.
JavaScript
1
4
1
this.client = new Client({
2
intents: [GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMessages, GatewayIntentBits.Guilds],
3
});
4