I'm trying to make my bot move users between channels automatically, to make a "cool-looking effect". For example, a user is in channel "1" and the bot has to move him to channel "2", then channel "3" etc.
The problem
I can't really find a way to move a mentioned user to another channel. I know this
member.voice.setChannel()
is used to, well, move a user into a specified channel but it doesn't work.
What I tried
client.on('message', message => {
if(!message.author.bot) {
if(message.content.startsWith('.move')) {
const member = message.mentions.users.first();
const channel = message.guild.channels.cache.get("770310636726517760"); //spazio1
member.voice.setChannel(channel)
}
}});
I tried the code above but it gives me this error TypeError: Cannot read property 'setChannel' of undefined
.
I searched online for hours and didn't find anything that could help me. I only found a piece of code that would move every user to a specified user's voice chat. I tried to adapt that to my needs, but it didn't work.