Node.js版本:10.15.3
操作系统:Windows 10
范围(安装,代码,运行时,元数据等):代码
我正在尝试为Discord Bot设置一个简单的昵称功能,但是当我输入“!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);
谢谢!
答案 0 :(得分:0)
该错误表明您的漫游器缺少权限。为了对成员执行管理操作,它需要“管理昵称”,并且可能需要一个高于成员最高角色的角色。