Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.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 “类型错误”;成员“提到.添加角色”;这不是一种功能_Javascript - Fatal编程技术网

Javascript “类型错误”;成员“提到.添加角色”;这不是一种功能

Javascript “类型错误”;成员“提到.添加角色”;这不是一种功能,javascript,Javascript,我对此有问题,以下是脚本: const BaseCommand = require('../../utils/structures/BaseCommand'); const Discord = require(`discord.js`); module.exports = class RoleCommand extends BaseCommand { constructor() { super('role', 'moderation', []); } async run(c

我对此有问题,以下是脚本:

const BaseCommand = require('../../utils/structures/BaseCommand');
const Discord = require(`discord.js`);

module.exports = class RoleCommand extends BaseCommand {
  constructor() {
    super('role', 'moderation', []);
  }
  async run(client, message, args) {
    const boss = `771038742105554954`;
    const test = `777879102296293416`;
    let member_mentions = message.mentions.members.first();
    if (args[1] === `test`){
      member_mentions.addroles(test).catch(console.error);
    }
    
  }
}
控制台错误:


(节点:9316)未处理的PromisejectionWarning:TypeError:member_提到。addroles不是函数 在RoleCommand.run(C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your\u boss\src\commands\moderation\RoleCommand.js:13:23) 在MessageEvent.run(C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your\u boss\src\events\message\message.js:17:17) 在Client.emit(events.js:315:20) 在MessageCreateAction.handle(C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your\u boss\node\u modules\discord.js\src\client\actions\MessageCreate.js:31:14) 在Object.module.exports[作为消息\u CREATE](C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your\u boss\node\u modules\discord.js\src\client\websocket\handlers\MESSAGE\u CREATE.js:4:32) 在WebSocketManager.handlePacket(C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your\u boss\node\u modules\discord.js\src\client\websocket\WebSocketManager.js:384:31) 在WebSocketShard.onPacket(C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your_boss\node\u modules\discord.js\src\client\websocket\WebSocketShard.js:444:22) 在WebSocketShard.onMessage(C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your_boss\node\u modules\discord.js\src\client\websocket\WebSocketShard.js:301:10) 在WebSocket.onMessage(C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your\u boss\node\u modules\ws\lib\event target.js:125:16) 在WebSocket.emit(events.js:315:20) (使用
节点--跟踪警告…
显示创建警告的位置)
(节点:9316)未处理的PromisejectionWarning:未处理的承诺拒绝。此错误源于在没有catch块的异步函数中抛出,或者拒绝未使用.catch()处理的承诺。要在未处理的承诺拒绝时终止节点进程,请使用CLI标志
--unhandled rejections=strict
(请参阅)。(拒绝id:1) (节点:9316)[DEP0018]弃用警告:未处理的承诺拒绝已弃用。将来,未处理的承诺拒绝将使用非零退出代码终止Node.js进程


它的javascript带有Slappey

Addroles
是不正确的。有效的用法是
roles.add()
,我也给你留了一个正确的脚本

let member = message.mentions.members.first();
let namerol = args.slice(1).join(' ');

let role = message.guild.roles.cache.find(r => r.name === namerol);
let perms = message.member.hasPermission("MANAGE_ROLES");

if(!perms) return message.channel.send("You don't have perms to use this command.");
if(!member) return message.reply('Please mention a user, to add role!');
if(!namerol) return message.channel.send('Please, mention the role to give the user.');
if(!role) return message.channel.send('Role not found!.');

miembro.roles.add(role)

“UnhandledPromisejectionWarning:TypeError:无法读取未定义的属性'add'”或“UnhandledPromisejectionWarning:ReferenceError:miembro未定义”是否确定?如果你愿意,你可以帮我