Feature Description
Allow Discord access control based on Discord roles (e.g., Moderator role) instead of hardcoded user IDs. Currently DISCORD_ALLOWED_USERS only accepts a comma-separated list of user IDs, which requires manual updates when moderator ranks change.
Motivation
Server moderation teams change frequently. Currently when a new moderator is added, someone must manually update DISCORD_ALLOWED_USERS with their Discord user ID. This is error-prone and requires ongoing maintenance.
A role-based approach would let moderators self-serve: grant the role on the server, and access is automatic.
Proposed Solution
Add a new environment variable DISCORD_ALLOWED_ROLES that accepts Discord role IDs:
DISCORD_ALLOWED_ROLES=1493705176387948674
DISCORD_ALLOWED_USERS=413720629
Behavior:
- If
DISCORD_ALLOWED_ROLES is set, resolve the configured roles to members via the Discord API
- Check if the message author has any of the allowed roles
- Both
DISCORD_ALLOWED_USERS and DISCORD_ALLOWED_ROLES can coexist (union)
- Resolved role memberships are cached and refreshed periodically (e.g., on gateway restart or on interval)
Implementation notes:
- Use Discord Guild API to resolve roles to member lists
- Placeholder for non-numeric entries in
DISCORD_ALLOWED_USERS already exists: _resolve_allowed_usernames()
- A similar
_resolve_allowed_roles() method could follow the same pattern
Alternatives Considered
- Sync script — Run an external cron job that syncs role members to
DISCORD_ALLOWED_USERS. Works but adds operational complexity and a delay between granting role and granting access.
- Bot mention + role check — Keep current mention-based auth but check roles regardless of user ID. Doesn't solve the maintainability problem.
Feature Description
Allow Discord access control based on Discord roles (e.g., Moderator role) instead of hardcoded user IDs. Currently
DISCORD_ALLOWED_USERSonly accepts a comma-separated list of user IDs, which requires manual updates when moderator ranks change.Motivation
Server moderation teams change frequently. Currently when a new moderator is added, someone must manually update
DISCORD_ALLOWED_USERSwith their Discord user ID. This is error-prone and requires ongoing maintenance.A role-based approach would let moderators self-serve: grant the role on the server, and access is automatic.
Proposed Solution
Add a new environment variable
DISCORD_ALLOWED_ROLESthat accepts Discord role IDs:Behavior:
DISCORD_ALLOWED_ROLESis set, resolve the configured roles to members via the Discord APIDISCORD_ALLOWED_USERSandDISCORD_ALLOWED_ROLEScan coexist (union)Implementation notes:
DISCORD_ALLOWED_USERSalready exists:_resolve_allowed_usernames()_resolve_allowed_roles()method could follow the same patternAlternatives Considered
DISCORD_ALLOWED_USERS. Works but adds operational complexity and a delay between granting role and granting access.