Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在Discord.js中担任最高角色_Javascript_Node.js_Discord.js - Fatal编程技术网

Javascript 在Discord.js中担任最高角色

Javascript 在Discord.js中担任最高角色,javascript,node.js,discord.js,Javascript,Node.js,Discord.js,我正在尝试执行do ban命令,我希望担任机器人的最高角色,并且要被禁止,我正在使用以下命令: let banlanan = message.mentions.users.first(); “班兰南”是指被禁止的人 但我得到了一个错误: (node:7299) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'highest' of undefined at Object.exports.run (/app/c

我正在尝试执行do ban命令,我希望担任机器人的最高角色,并且要被禁止,我正在使用以下命令:

let banlanan = message.mentions.users.first();
“班兰南”是指被禁止的人

但我得到了一个错误:

(node:7299) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'highest' of undefined
at Object.exports.run (/app/commands/ban.js:58:38)
at Client.module.exports (/app/events/message.js:18:9)
    at Client.emit (events.js:196:13)
    at MessageCreateAction.handle (/rbd/pnpm-volume/8f956760-d64c-490a-a07c-4ad3ee571e52/node_modules/.registry.npmjs.org/discord.js/12.4.1/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (/rbd/pnpm-volume/8f956760-d64c-490a-a07c-4ad3ee571e52/node_modules/.registry.npmjs.org/discord.js/12.4.1/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/rbd/pnpm-volume/8f956760-d64c-490a-a07c-4ad3ee571e52/node_modules/.registry.npmjs.org/discord.js/12.4.1/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (/rbd/pnpm-volume/8f956760-d64c-490a-a07c-4ad3ee571e52/node_modules/.registry.npmjs.org/discord.js/12.4.1/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (/rbd/pnpm-volume/8f956760-d64c-490a-a07c-4ad3ee571e52/node_modules/.registry.npmjs.org/discord.js/12.4.1/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
    at WebSocket.onMessage (/rbd/pnpm-volume/8f956760-d64c-490a-a07c-4ad3ee571e52/node_modules/.registry.npmjs.org/ws/7.4.0/node_modules/ws/lib/event-target.js:132:16)
    at WebSocket.emit (events.js:196:13)
(node:7299) 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: 1)
(node:7299) [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.
请原谅我用英语翻译。

没有角色属性。如果您想获取客户机的实例,应该使用

让banlananroles=banlanan.roles.highest.position;
让botroles=message.guild.me.roles.highest.position;
if(banlananroles>botroles){
message.channel.send(
“你想让我禁止的人的角色比我高,所以我不能禁止。”
);
返回;
}
没有角色属性。如果您想获取客户机的实例,应该使用

让banlananroles=banlanan.roles.highest.position;
让botroles=message.guild.me.roles.highest.position;
if(banlananroles>botroles){
message.channel.send(
“你想让我禁止的人的角色比我高,所以我不能禁止。”
);
返回;
}

我这样做解决了错误

let banlananrol = message.guild.member(banlanan).roles.highest.position;
let botrol = message.guild.member(client.user).roles.highest.position;

无论如何谢谢我这样做解决了错误

let banlananrol = message.guild.member(banlanan).roles.highest.position;
let botrol = message.guild.member(client.user).roles.highest.position;

不管怎样,谢谢我做了,但是我的错误还在继续,同样的错误我做了,但是我的错误还在继续,同样的错误