I want to move all member within an array into a channel. The array memberIDs contains the IDs from the Member I want to move. The variable gameChannel contains the channel id as a string. My Code looks like this:
memberIDs.forEach(element => message.guild.member(element).voice.setChannel(gameChannel));
To move a member you must first get its data (GuildMember) and then move it.
Discord.js^12
var gameChannel = 'CHANNEL_ID';
var memberIDs = ['SOME_ID_HERE', 'OTHER_ID_HERE', '...'];
// For each element of the 'MemberIDs'
memberIDs.forEach(id => {
// Assuming 'guild' is the Server Guild
var member = guild.member.cache.get(id); // Get member
if(member){
// Move
member.voice.setChannel(gameChannel, 'reason (this can be empty)')
.then(e => console.log('User moved successfully'))
.catch(e => console.log('An error occurred while trying to move the user'));
}
});