Allow modification of existing permissions in ChannelAction
See original GitHub issueInspired by discord/discord-api-docs#2520
General Troubleshooting
- I have checked for similar issues.
- I have updated to the [latest JDA version][download].
- I have checked the branches or the maintainers’ PRs for upcoming features.
Feature Request
I would like a way to view and update existing permission overrides from a ChannelAction
object.
Example Use-Case
Because of discord/discord-api-docs#2520, when using JDA’s Category#createVoiceChannel
you must now sanitise out all MANAGE_ROLES
permissions unless the bot is given admin permissions. Currently I’m just using this as a quick hack, which is not ideal:
private object JDAHack {
lazy val field: Field = {
val f = classOf[ChannelActionImpl[_]].getDeclaredField("overrides")
f.setAccessible(true)
f
}
def removeManageRolesPerms(channelReq: ChannelAction[_]): Unit = {
try {
val overrides = field.get(channelReq).asInstanceOf[TLongObjectHashMap[PermOverrideData]]
overrides.transformValues { v =>
val manageRoles = Permission.MANAGE_ROLES.getRawValue
new PermOverrideData(v.`type`, v.id, v.allow & ~manageRoles, v.deny & ~manageRoles)
}
} catch {
case NonFatal(_) =>
}
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
dv8tion discord java channel permissions - Stack Overflow
You can modify permissions on the ChannelAction returned by createTextChannel . The addPermissionOverride method allows to add overrides for ...
Read more >Give staff permissions with POS roles - Shopify Help Center
Store owners, or staff with the Manage POS roles permission, can edit roles to allow Manager approval. To approve an action, staff need...
Read more >ChannelAction (JDA 4.4.0_352 API)
allow - The granted Permissions for the override. Use Permission. getRawValue() to retrieve these Permissions. deny - The denied Permissions for the override....
Read more >Guest Star Mod View - Twitch Help
Guest Star Mod View is an additional moderation tool of a channel's current Mod View, allowing specific mod access and privileges specific to...
Read more >Modify File Permissions with chmod - Linode
The chmod command allows users to change read and write permissions in Unix systems. In this guide, we will show you how to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I considered those, but using
createVoiceChannel
on the guild leaves me the problem of not taking permissions from the category (e.g. voice ban and priority speaker roles), and replacing withaddPermissionOverride
requires that I know exactly which permissions have that kill-bit in them in the first place.You can also use
ChannelAction#addPermissionOverride
to replace existing overrides.