Skip to content

Identify and fix potential forbidden errors due to role hierarchy #905

@MarkKoz

Description

@MarkKoz

Sometimes discord.Forbidden errors are raised due to the bot being lower in the role hierarchy than the user they are trying to edit. An example of this is joe trying to superstarify himself (see BOT-3C).

Depending on which groups of users this affects, we should try to gracefully handle such error. If this only affects the server owner (as in, true ownership, not just the role we have), the we could ignore it. If it affects roles like admins and mods, then I think we should address this error.

Unfortunately, I don't think Discord's API distinguishes between someone being too low in the hierarchy and the bot not having permissions granted. If we want to log the latter as much as possible, then we couldn't do a blanket ignore (or lower log level) on all discord.Forbidden exceptions. However, if we think it's safe to assume the bot will always have the right permissions, then maybe such an ignore is a valid solution. Otherwise, potential errors specifically do to hierarchy will need to be handled individually. For those errors, we'd have to assume that it's due to role hierarchy and not the bot missing permissions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: backendRelated to internal functionality and utilities (error_handler, logging, security, utils and core)p: 3 - lowLow Prioritys: planningDiscussing detailst: bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions