question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow modification of existing permissions in ChannelAction

See original GitHub issue

Inspired 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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ScoreUndercommented, Jan 23, 2021

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 with addPermissionOverride requires that I know exactly which permissions have that kill-bit in them in the first place.

0reactions
MinnDevelopmentcommented, Jan 23, 2021

You can also use ChannelAction#addPermissionOverride to replace existing overrides.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found