Gio23
Gio23

Reputation: 37

setChannel is undefined

I'm trying to make a simple command that moves the mentioned user back and forth, but I get an error message that setChannel is undefined.

Here is my code:

module.exports ={
    name:'bully',
    description: "something",
    execute(message, args, Discord, client){
       const GuildMember = message.mentions.users.first();
       const channel1 = GuildMember.voiceChannel;
       const channel2 = '785599712677462016';
       GuildMember.voice.setChannel('channel1');
       GuildMember.voice.setChannel('channel2');
       GuildMember.voice.setChannel('channel1');
    }
}

Upvotes: 0

Views: 74

Answers (1)

MrMythical
MrMythical

Reputation: 9041

GuildMember is not what it's supposed to be. Here, it’s actually defined as an instance of User.

To fix it, change it from MessageMentions.users to MessageMentions.members so you get a GuildMember

const GuildMember = message.mentions.members.first()

Upvotes: 2

Related Questions