Change user nickname with discord.js

前端 未结 11 1449
清酒与你
清酒与你 2020-12-16 19:15

I wonder if you can help (I search it and nothing...) I am learning how to work with discord.js node and I want to change my user nickname (not the username itself)

11条回答
  •  南笙
    南笙 (楼主)
    2020-12-16 19:49

    like @Zaidhaan said, heres a little snippet that only trys to set the nickname if it has the perms

        if (message.guild.members.get(bot.user.id).hasPermission("MANAGE_NICKNAMES") && message.guild.members.get(bot.user.id).hasPermission("CHANGE_NICKNAME")) {
            message.guild.members.get(bot.user.id).setNickname("Nickname Here");
        } else {
            message.channel.sendMessage("I dont have the permissons to change my nickname in this server.");
        }
    

    since your getting the user via message.guild.members.get() it requires the perms to edit nicknames on the server

提交回复
热议问题