1

I am trying to move the tagged user into the voice channel using the channel ID. I saw someone use .setUserChannel but it tells me that it isn't a function. Can someone tell me what I need to fix please :)

    if(command === 'ping'){
    message.channel.send('pong');
} else if (command === 'abuse'){
            //const AbuseTown = client.channel.cache.get(760535995329282161);
            const taggedUser = message.mentions.users.first();
            message.channel.send(`You want to abuse: ${taggedUser.username}`);
            taggedUser.setVoiceChannel('776202269569712168');
            return;
        }

1 Answers1

0

First of all, you need the GuildMember object, not the User object. Learn more about the difference here

// change:
const taggedUser = message.mentions.users.first();

// to:
const taggedUser = message.mentions.members.first();

Second of all, GuildMember.setVoiceChannel() is an outdated function, so it won't work if you're using v12.x. Instead, use VoiceState.setChannel().

const taggedUser = message.mentions.members.first();
message.channel.send(`You want to abuse: ${taggedUser.username}`);
taggedUser.voice.setChannel('776202269569712168');
Lioness100
  • 8,260
  • 6
  • 18
  • 49
  • Thank you so much, i've got it working now. Have a good day :) – Benson_Jack Nov 12 '20 at 09:30
  • Glad I could help. Please mark my answer as accepted if it solved your problem, as it will be easier to find for others in the future who have the same issue. – Lioness100 Nov 12 '20 at 11:42