Skip to content

feat: allow staff to assign roles on behalf of users - #954

Closed
majestic-owl448 wants to merge 2 commits into
mainfrom
feat/staff-role-assign
Closed

feat: allow staff to assign roles on behalf of users#954
majestic-owl448 wants to merge 2 commits into
mainfrom
feat/staff-role-assign

Conversation

@majestic-owl448

Copy link
Copy Markdown
Contributor

Checklist:

Closes #943

Adds /management assign-role, which toggles a role for a target member the same way the self-serve role buttons do. Moderators can now sort out campers who cannot work the onboarding UI.

The role option is autocompleted, and the list is computed live rather than configured: every role below the CamperChan's own highest role, minus the everyone role and minus roles owned by an integration, such as the booster role. Nothing to maintain when roles are added, moved, or removed. The same check runs again when the command executes, since a client can submit any string to an autocompleted option.

Autocomplete had no plumbing in this repository, so the first commit adds it: an optional autocomplete handler on the command and subcommand interfaces, plus a branch in handleInteractionCreate that dispatches to it. Every path there responds, because Discord accepts nothing but a choice list for these interactions and the camper's client hangs until timeout otherwise. The management command routes autocomplete through the same subcommand map as run, and runs the permission validator first, so non moderators get an empty list.

Role changes are posted to the mod webhook, in the same plain content style as the voice reports:

<@moderator> has added the `AI` role to <@camper>.

Discord's audit log credits the CamperChan for the change, so without this there is no record of which moderator made it. The role is named rather than mentioned, so the log cannot ping everyone holding a mentionable role.

No configuration or permission changes are needed to deploy this. Commands are registered on boot, and the Manage Roles permission and the GuildMembers intent are both already in use.

Adds an optional autocomplete handler to the command and subcommand
interfaces, and dispatches autocomplete interactions to it. Every path
responds, since Discord only accepts a choice list for these.
Adds a management assign-role subcommand that toggles a role for the
target member, mirroring the self-serve role buttons. The role option is
autocompleted with every role below the camperChan's own highest role,
excluding the everyone role and integration-owned roles such as the
booster role. Changes are logged to the mod webhook, since Discord's
audit log credits the camperChan rather than the moderator.

Closes #943
@majestic-owl448
majestic-owl448 requested a review from a team as a code owner August 4, 2026 06:54

@naomi-freecodecamp naomi-freecodecamp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blocking while discussing on discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: allow staff to manage self-assignable roles on behalf of users

2 participants