Javascript Discord.js中的set昵称问题

Javascript Discord.js中的set昵称问题,javascript,discord.js,Javascript,Discord.js,Node.js版本:10.15.3 操作系统:Windows 10 范围(安装、代码、运行时、元、其他?):代码 我正在尝试为我的Discord Bot设置一个简单的nick命名函数,但当我键入“!setNickname@username”时,它会显示以下错误消息: (node:20440) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions at item.request.gen.end (C:\Code

Node.js版本:10.15.3

操作系统:Windows 10

范围(安装、代码、运行时、元、其他?):代码

我正在尝试为我的Discord Bot设置一个简单的nick命名函数,但当我键入“!setNickname@username”时,它会显示以下错误消息:

(node:20440) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions at item.request.gen.end (C:\Code\ACCBot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85:15) at then (C:\Code\ACCBot\node_modules\snekfetch\src\index.js:215:21) at process._tickCallback (internal/process/next_tick.js:68:7) (node:20440) 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(). (rejection id: 2) (node:20440) [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.
这是我的代码:(前缀是!)


提前谢谢

该错误表示您的机器人缺少权限。它需要管理昵称,并且可能需要一个高于成员最高角色的角色,以便对成员执行管理操作。

谢谢!我感谢你的帮助。
const Discord = require('discord.js'); //looks in node_modules folder for discord.js
const {prefix, token} = require('./config.json');
const client = new Discord.Client();

client.once('ready', () => {
    console.log('Ready!')
})

client.on('message', message => { 

    if(message.content.startsWith(`${prefix}setNickname`)){

        let member = message.mentions.members.first();
        member.setNickname('cool guy').then((member) => {
            message.channel.send(member.displayName + "is a cool guy")
        })
    }
})

client.login(token);