Connecting a specific client to a voice channel

Hello, I'm trying to make a distributed music bot service for a single guild. Long story (https://stackoverflow.com/questions/75860115/is-there-a-way-to-connect-a-specific-discord-js-client-to-a-voice-channel) short, I've logged in several other clients I'd like to have connect to a voice channel when a user uses /play. The main bot that receives the command runs
const channel = interaction.member.voice.channel;
const { joinVoiceChannel } = require('@discordjs/voice');
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator
});
const channel = interaction.member.voice.channel;
const { joinVoiceChannel } = require('@discordjs/voice');
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator
});
and causes the main bot to join. I don't see anything that specifies which client is connecting, so I'm stumped on what to do. Ideally, I'd do something simple like client.voice.join(channel); but that doesn't seem possible from what I've seen.
Stack Overflow
Is there a way to connect a specific Discord.js client to a voice c...
I'm trying to make a distributed music-playing bot for a single guild/server. This involves a single bot taking in commands from the server members and assigning "loudspeaker" bots to their
4 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
CombustibleToast
CombustibleToastOP2y ago
node --version
v18.12.1


npm list discord.js
node --version
v18.12.1


npm list discord.js
duck
duck2y ago
the adapter creator used in joinVoiceChannel is what determines what client connects <Guild>.voiceAdapterCreator will be for the Client that instantiated the Guild object however because of how /voice handles grouping and reusage of connections, you'd also need to specify a different group for each client in the joinVoiceChannel options this also means you'd need the same group when accessing the connection with getVoiceConnection the group only needs to be unique between each client, so you could use something like each client's id as a side note unrelated to your issue, you should probably ensure djs and djs/voice are up to date as a few major issues were fixed in the latest releases
CombustibleToast
CombustibleToastOP2y ago
Thanks for the insight!
Want results from more Discord servers?
Add your server