Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
Getting "Missing Access" error in console

I'm working on an add role command in discord.js v13 and this is the error I am getting: Error

const { MessageEmbed } = require("discord.js");
const Discord = require("discord.js")
const config = require("../../botconfig/config.json");
const ee = require("../../botconfig/embed.json");
const settings = require("../../botconfig/settings.json");

module.exports = {
  name: "addrole",
  category: "Utility",
  permissions: ["MANAGE_ROLES"],
  aliases: ["stl"],
  cooldown: 5,
  usage: "addrole <user> <role>",
  description: "Add a role to a member",

  run: async (client, message, args, plusArgs, cmdUser, text, prefix) => {

    /**
     * @param {Message} message
    */

    if (!message.member.permissions.has("MANAGE_ROLES")) return message.channel.send("<a:mark_rejected:975425274487398480> **You are not allowed to use this command. You need `Manage Roles` permission to use the command.**")

    const target = message.mentions.members.first();
    if (!target) return message.channel.send(`<a:mark_rejected:975425274487398480> No member specified`);
    const role = message.mentions.roles.first();
    if (!role) return message.channel.send(`<a:mark_rejected:975425274487398480> No role specified`);

    await target.roles.add(role)
    message.channel.send(`<a:mark_accept:975425276521644102> ${target.user.username} has obtined a role`).catch(err => {
      message.channel.send(`<a:mark_rejected:975425274487398480> I do not have access to this role`)
    })
  }
}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

What your error means is that your bot doesn't have permissions to give a role to a user. It might be trying to add a role which has a higher position than the bot's own role. One way to stop the error is to give the bot the highest position. The bot will also require the MANAGE_ROLES permission in the Discord Developers page to successfully add roles in the first place. If you want to learn more about role permissions, I suggest you go here => Roles and Permissions. Also, when you are using .catch() at the end, all it is checking for is if the message.channel.send() at the end worked and if not, then send a message to channel telling that the bot was not able to add the role. Instead you need to use .then() after adding the role and then use .catch() to catch the error. Then, your code might look like this:

target.roles.add(role).then(member => {
    message.channel.send(`<a:mark_accept:975425276521644102> ${target.user.username} has obtined a role`)
}).catch(err => {
    message.channel.send(`<a:mark_rejected:975425274487398480> I do not have access to this role`)
})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!