Firstly, to get a GuildMember
from a User
, there are a few options.
- Use
Guild#member
. This function has already been removed in the master
branch, and probably won't be included in future versions, but it's currently still very usable.
const user = ...
const guild = ...
const member = guild.member(user);
const user = ...
const guild = ...
const member = guild.members.cache.get(user.id);
You can find the VoiceChannel
the member is in through their VoiceState
. Every VoiceState
has a channel
property referencing the voice channel they are currently in, or null
if no channel was found.
const member = ...
const channel = member.voice.channel;
if (channel) channel.join();