Add is_admin() helper to utils/permissions.py
#55
Labels
No Label
ai-changes-requested
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
in-next-release
status/in-progress
status/pr-open
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-v2#55
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Multiple places in the codebase manually check
interaction.user.guild_permissions.administratorwith slightly inconsistent patterns:InjuryGroup._verify_team_ownershipincludesisinstance(interaction.user, discord.Member)guard (correct)can_edit_player_imageincommands/profile/images.pyskips theisinstancecheck (would raiseAttributeErrorin DM context)admin_only()decorator inutils/permissions.pyincludes the guardA simple
is_admin(interaction: discord.Interaction) -> boolhelper inutils/permissions.pywould centralize this and prevent inconsistencies:PR #64 opened: #64
Added
is_admin(interaction)helper toutils/permissions.pywith theisinstance(interaction.user, discord.Member)guard, then updatedcan_edit_player_image()incommands/profile/images.pyto use it (fixing the missing DM-safety guard). Updated the admin test mock to usespec=discord.Member. All 930 tests pass.