具有权限ADMINISTRATOR的Discord机器人缺少权限MANAGE_CHANNEL

时间:2019-06-09 21:15:52

标签: java discord discord-jda

当我使用OAUTH2 URL GENERATOR创建连接URL时,我的机器人授予了“ ADMINISTRATOR”权限。我无法提供其他任何权限,因为ADMINISTRATOR应该为机器人赋予所有权限。

加入我的机器人后,应检查是否存在窗帘通道,如果不存在则创建它。有问题。我收到以下错误:

[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)

这似乎是一个错误,因为正如我已经说过的那样,权限ADMINISTRATOR应该允许该机器人基本上执行所有操作(某些角色层次结构和服务器所有者的东西除外)。

有人知道如何解决此问题吗?

// EDIT1: 好的,我通过OAuth2授予​​了机器人除ADMINISTRATOR之外的所有权限,但结果基本相同。该漫游器只是没有应有的权限。我对OAuth2和网址生成器的工作方式有错误的理解吗?

1 个答案:

答案 0 :(得分:1)

bot的权限是通过Discord管理的角色添加的。不幸的是,在触发加入事件后 会添加此角色,因此权限尚未准备就绪。 There is an open issue about this on GitHub

您不必侦听加入事件,而必须侦听GuildMemberRoleAddEvent。 该角色应具有应用程序的名称,并且isManaged()返回true。