Coder Social home page Coder Social logo

Comments (3)

MinnDevelopment avatar MinnDevelopment commented on May 27, 2024

The HierarchyException is thrown by addRoleToMember, before you even call queue. Are you sure that you properly handle exceptions being thrown?

from jda.

sheiun avatar sheiun commented on May 27, 2024

The HierarchyException is thrown by addRoleToMember, before you even call queue. Are you sure that you properly handle exceptions being thrown?

When I call the method guild.addRoleToMember it didn't throw any exception.
And the bot did have the permission to manage the role but the roles higher than the bot's role will not work.

And no matter the bot's role is higher or lower than the target the method won't throw the exception.

from jda.

MinnDevelopment avatar MinnDevelopment commented on May 27, 2024

I just tried this again, and it definitely throws an exception:

net.dv8tion.jda.api.exceptions.HierarchyException: Can't modify a role with higher or equal highest role than yourself! Role: Role:highest role(id=280161492307804160)
	at net.dv8tion.jda.internal.entities.GuildImpl.checkPosition(GuildImpl.java:2031)
	at net.dv8tion.jda.internal.entities.GuildImpl.addRoleToMember(GuildImpl.java:1688)

Since you also called your variable linkedRole, it might refer to a managed role, in which case the request fails with a failure callback:

[pool-1-thread-11] ERROR RestAction - RestAction queue returned failure: [ErrorResponseException] 50013: Missing Permissions
net.dv8tion.jda.api.exceptions.ContextException
	at net.dv8tion.jda.api.exceptions.ContextException.here(ContextException.java:54)
	at net.dv8tion.jda.api.requests.Request.<init>(Request.java:77)
	at net.dv8tion.jda.internal.requests.RestActionImpl.queue(RestActionImpl.java:203)
	at net.dv8tion.jda.api.requests.RestAction.queue(RestAction.java:573)
	at net.dv8tion.jda.api.requests.RestAction.queue(RestAction.java:539)

The same happens if for some reason the position check in JDA fails.

Please give me an easy to reproduce test-scenario, if you still encounter issues. Otherwise, I have to assume this issue is an incorrect handling of exceptions on your end.

from jda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.