每次我嘗試使用我的機器人更改服務器中其他人的昵稱(甚至是朋友的服務器中的我自己),它都會失敗,給我帶來以下錯誤:(node:11620) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions at RequestHandler.execute (C:\Users\(User)\Desktop\Discord Bot\Nick-Cycle\node_modules\discord.js\src\rest\RequestHandler.js:170:25) at processTicksAndRejections (internal/process/task_queues.js:97:5)(node:11620) 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 handledwith .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:11620) [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.我檢查了一下,它確實有管理昵稱,它的角色就在所有者下面。我試圖改變昵稱的人,他的最高角色遠遠低于機器人。機器人的角色、職位和管理昵稱權限的圖像。代碼如下:client.on('message', async message => { const prefix = ";" if (message.author.bot) return; if (!message.guild) return; if (!message.content.startsWith(prefix)) return; const args = message.content.slice(prefix.length).trim().split(/ +/g); const cmd = args.shift().toLowerCase(); switch(cmd) { case "setnick": if (!message.guild.me.hasPermission("MANAGE_NICKNAMES")) return message.channel.send("I don't have Manage Nicknames!"); if (!args[0]) return message.channel.send("Not enough arguments!"); if (args[0] === getUserFromMention(args[0])) { const user = getUserFromMention(args[0]) if (!args[1]) return message.channel.send("Not enough arguments!"); message.guild.members.fetch(user).setNickname(args[1]); } else { message.member.setNickname(args[0]); } break; } });怎么了?這是一個小故障嗎?角色中是否有問題?還是我的代碼有問題?
在不和諧中更改昵稱時缺少權限錯誤.js
Cats萌萌
2022-08-18 16:08:32