it won't let me change the nickname discord.js

Viewed 535

client.on("message", async (message) => { let roles = { : "Owner", ADMIN: "[ADM]", Moderador: "[MOD]", DcMod: "[DC]", Booster: "[BOOST]", Usuario: "[USER]"

}


let nombrerol = message.member.roles.cache.size <= 1 ? "Usuario" : message.member.roles.highest.name;


message.member.setNickname(`${roles[nombrerol]} ${message.author.username}`) })

and I get this error

(node:2604) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
    at RequestHandler.execute (E:\Bots\Skyliner[RP] Bots\XD\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async RequestHandler.push (E:\Bots\Skyliner[RP] Bots\XD\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
    at async GuildMember.edit (E:\Bots\Skyliner[RP] Bots\XD\node_modules\discord.js\src\structures\GuildMember.js:312:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2604) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2604) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2 Answers

Means your bot does not have permissions to update the user's nickname. Try giving the bot those permissions and see what it does.

Related