0
votes

I am having problem with this and here is the script:

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);
    }
    
  }
}

The console error:

(node:9316) UnhandledPromiseRejectionWarning: TypeError: member_mentions.addroles is not a function at RoleCommand.run (C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your_boss\src\commands\moderation\RoleCommand.js:13:23) at MessageEvent.run (C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your_boss\src\events\message\message.js:17:17) at Client.emit (events.js:315:20) at MessageCreateAction.handle (C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your_boss\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14) at Object.module.exports [as MESSAGE_CREATE] (C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your_boss\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your_boss\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31) at WebSocketShard.onPacket (C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your_boss\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22) at WebSocketShard.onMessage (C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your_boss\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10) at WebSocket.onMessage (C:\Users\maksy\Desktop\super bot test\super bot test\your boss\data\your_boss\node_modules\ws\lib\event-target.js:125:16) at WebSocket.emit (events.js:315:20) (Use node --trace-warnings ... to show where the warning was created) (node:9316) 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(). 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:9316) [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.

its javascript with Slappey

1

1 Answers

0
votes

Addroles is incorrect the valid use is roles.add(), also I leave you a script which would be correct.

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)