Skip to content

Incorrect humanization of format_perms_list for MANAGE_ROLES in channel contexts #6653

@Vexed01

Description

@Vexed01

What component of Red (cog, command, API) would you like to see improvements on?

API - utils.chat_formatting

Describe the enhancement you're suggesting.

Currently, format_perms_list assumes a guild context when humanizing MANAGE_ROLES. This is problematic because in the Discord client UI, at channel/category level the MANAGE_ROLES permission is shown as "Manage Permissions" while at role-level it is "Manage Roles".

This leads to the behaviour where if "Manage Permissions" is disabled for a role/user at channel level and @commands.bot_has_permissions(manage_roles=True) decorator is added, the bot will say that the "Manage Roles" permission is required when it is actually the "Manage Permissions" permission that needs to be granted (even if Manage Roles is given at role-level, this will still happen if Manage Permissions is explicitly denied at channel-level).

I "fixed" this in my cog by changing the deco to bot_has_guild_permissions as that was the behaviour I actually intended.

Therefore the format_perms_list util should have an optional arg for channel context and which would have the functionaliy of replacing Manage Roles with Manage Permissions

Anything else?

I wrote this for format_perms_list before realising I wasn't sure how to implement checking if MANAGE_ROLES was denied at channel or role/user level. Or maybe I'm just overthinking. I can PR just this if wanted.

Example diagnose issues output when the bot has Manage Role permissions but has Manage Permissions explicitly denied at channel-level, so it is misleading
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Needs TriageThis has not been labeled or discussed for handling yet.Type: BugUnexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions