#Connecting a specific client to a voice channel

6 messages · Page 1 of 1 (latest)

lean reef
#

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
});

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.

kind stratus
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

lean reef
stoic pine
#

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