1

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.

Kikkiu
  • 85
  • 3
  • 13
  • Just for future reference, `Cannot read property x of undefined` errors do not mean `x` is undefined or not working. It means what it was *called on* is undefined. In this case, `member.voice` – Lioness100 Oct 27 '20 at 17:14
  • Does this answer your question? [What is the difference between a User and a GuildMember in discord.js?](https://stackoverflow.com/questions/63979076/what-is-the-difference-between-a-user-and-a-guildmember-in-discord-js) (`message.mentions.users.first()` should be `message.mentions.members.first()`) – Lioness100 Oct 27 '20 at 17:15

0 Answers0