0

I write a bot and I write command to change nickname

if (msg.content.startsWith(`${prefix}nick`)) {
    msg.author.setNickname({
      nick: msg.content.replace('nick ', '')
    });
  }

But i have errors

msg.author.setNickname is not a function

Please help me

neoney
  • 5
  • 2

1 Answers1

0

If you want to change a users nickname, you must make sure that the bot has permission to do so first. You can use the GuildMember#setNickname function like this:

 var pingeduser = message.guild.member(message.mentions.users.first()) ||
        message.guild.members.cache.get(args[0]);
      if (!pingeduser) return message.channel.send("Can't find user!");    
    var nick = message.content.split(" ").slice(1).join(" ");
    pingeduser.setNickname(nick);
shoe
  • 214
  • 1
  • 8