Determining if the client is currently in a specific voice channel
Does there currently exist a way to determine which voice channels the client is currently connected to? I see that the
ClientVoiceManager
provides an .adapters
map but I'm not too familiar with it.
My end goal is to prevent people from adding audio to the client's queue if they are in a separate voice channel but within the same guild.4 Replies
Would something as simple as this work?
Or is there a better way to get the client's currently connected voice channels?
to my knowledge, that adapter collection is mapped by guild id, not channel id
for your use case, I don't believe you'd need a list of all voice channels the client is connected to, just the one connected channel for a given guild, which can be achieved with
<Guild>.members.me.voice.channel
or <Guild>.members.me.voice.channelId
however if you feel you do need a list of channels, I'm unsure if there's a direct way through djs
getVoiceConnections
exists in djs/voice for getting voice connection groups, so if all connections were declared in a group that could work
other ways involve storing channel ids yourself and iterating/filtering through all guilds for connectionsI think in this case
<Guild>.members.me.voice.channelId
may work! I didn't realize that the client could be fetched from the guild members list. That makes things a whole lot easier! I'll compare the voice channel of the user that performed the interaction to the one the client is currently connected to in that guild (if any)
I also see your point about the adapter mapping. You are correct, it maps guild id to object, not channel id. That's my mistake.
Thank you very much for your response👍