Danny
Danny

Reputation: 842

Discord bot with permission ADMINISTRATOR lacks of permission MANAGE_CHANNEL

When I create the join-url with the OAUTH2 URL GENERATOR I give my bot the permission "ADMINISTRATOR". I can't provide any other permission, because ADMINISTRATOR should give the bot every permission.

After joining my bot should check if a curtain channel exists and create it if not. There is the problem. I'm getting the following error:

[JDA MainWS-ReadThread] ERROR net.dv8tion.jda.core.JDA - One of the             
EventListeners had an uncaught exception
net.dv8tion.jda.core.exceptions.InsufficientPermissionException: Cannot 
perform action due to a lack of Permission. Missing permission: MANAGE_CHANNEL
at net.dv8tion.jda.core.managers.GuildController.checkPermission(GuildController.java:2247)
at net.dv8tion.jda.core.managers.GuildController.createTextChannel(GuildController.java:1762)
at listeners.selfJoinListener.onGuildJoin(selfJoinListener.java:156)
at net.dv8tion.jda.core.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:513)
at net.dv8tion.jda.core.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:84)
at net.dv8tion.jda.core.handle.GuildSetupNode.completeSetup(GuildSetupNode.java:381)
at net.dv8tion.jda.core.handle.GuildSetupNode.handleMemberChunk(GuildSetupNode.java:284)
at net.dv8tion.jda.core.handle.GuildSetupNode.ensureMembers(GuildSetupNode.java:410)
at net.dv8tion.jda.core.handle.GuildSetupNode.handleCreate(GuildSetupNode.java:243)
at net.dv8tion.jda.core.handle.GuildSetupController.onCreate(GuildSetupController.java:185)
at net.dv8tion.jda.core.handle.GuildCreateHandler.handleInternally(GuildCreateHandler.java:40)
at net.dv8tion.jda.core.handle.SocketHandler.handle(SocketHandler.java:37)
at net.dv8tion.jda.core.requests.WebSocketClient.onDispatch(WebSocketClient.java:868)
at net.dv8tion.jda.core.requests.WebSocketClient.onEvent(WebSocketClient.java:766)
at net.dv8tion.jda.core.requests.WebSocketClient.handleEvent(WebSocketClient.java:745)
at net.dv8tion.jda.core.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:903)
at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:368)
at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:270)
at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:990)
at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:749)
at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108)
at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64)
at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)

This seems like a bug, because as I already said, the permission ADMINISTRATOR should allow the bot to do basically everything (except some role hierachy and server owner stuff).

Does anyone have an idea how to solve this problem?

//EDIT1: Okay, I gave the bot every permission except ADMINISTRATOR via OAuth2, but the outcome is basically the same. The bot just doesn't have the permissions it should have. Do I have a wrong understanding of how OAuth2 and the url generator work?

Upvotes: 3

Views: 2108

Answers (1)

Minn
Minn

Reputation: 6134

The permissions for a bot are added through a role that is managed by Discord. Unfortunately this role is added after the join event is fired and thus permissions are not yet ready. There is an open issue about this on GitHub.

Instead of listening for the join event you would have to listen for the GuildMemberRoleAddEvent. The role should have the name of the application and have isManaged() return true.

Update: Discord has fixed the issue mentioned above and this should now work correctly. The aformentioned role is now present when the guild is joined rather than being added later.

Upvotes: 3

Related Questions