Admins can't assign roles

(#469) Bug Fixed moderation

Thread

Comment by @cproudlock
RexSystem 1 vote originally by @cproudlock on GitHub
Root cause: Two-part bug across frontend and gateway:
  1. Gateway (guild_members.erl::check_can_manage_roles): uses strict > comparison on role positions. When all non-everyone roles are at the same position (a common config), no admin can assign any role because their max position is never strictly greater than the target.
  1. Frontend (PermissionUtils.tsx::isRoleHigher): uses an indexOf on a sorted role list. When positions tie, sort order is unstable and the comparison is unreliable. The frontend disables the role menu before any request is sent.
The gateway already has correct equal-position tiebreaker logic in can_manage_role (singular) - it just wasn't applied to can_manage_roles (plural). Fix:
  • Gateway: add equal-position tiebreaker (lower role ID can manage equal-position role) to match the singular version
  • Frontend: replace indexOf comparison with direct position comparison + role ID tiebreaker
Verified working on a self-hosted instance.