Closed sheiun closed 2 months ago
The HierarchyException is thrown by addRoleToMember
, before you even call queue. Are you sure that you properly handle exceptions being thrown?
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.
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.
Closing due to inactivity.
General Troubleshooting
Version of JDA
v5.0.0-beta.23
Expected Behaviour
When we settings a bunch of roles inside a Discord server, the roles are ranked with level and when the BOT try to manage higher role, such as add higher role to a member, the API should throw some error to let me know this action is failed.
Code Example for Reproduction Steps
Code for JDABuilder or DefaultShardManagerBuilder used
Exception or Error
Throw an error to failure callback