fix: combine role_admin into admin cog for proper subgroup handling#182
Merged
fix: combine role_admin into admin cog for proper subgroup handling#182
Conversation
- Merge role_admin.py functionality into admin.py as single AdminCog - Define admin group and role subgroup as class attributes (matches CTF pattern) - Delete role_admin.py and its test file - Revert special loading order in __main__.py (no longer needed) This fixes the py-cord issue where subgroups defined at module level don't get their cog attribute set properly. The py-cord examples and working patterns (CtfCog) define command groups as class attributes inside the Cog.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #182 +/- ##
==========================================
- Coverage 64.76% 64.73% -0.04%
==========================================
Files 53 52 -1
Lines 3057 3043 -14
==========================================
- Hits 1980 1970 -10
+ Misses 1077 1073 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add tests for AdminCog role management commands: - add: success, with cert fields, invalid category - remove: success, not found, invalid category - update: success, not found, invalid category - list: empty, with data, category filter, role not in guild - reload: success - setup: registers cog Replaces test_role_admin.py with test_admin.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the
/admin rolecommands not appearing in Discord by combiningrole_admin.pyintoadmin.pyas a single cog. This follows py-cord's documented pattern for subgroups.Problem
The
/admingroup was defined at module level and registered viabot.add_application_command(), while therolesubgroup was created viaadmin.create_subgroup()in a different file. This caused py-cord to not properly set thecogattribute on the subgroup, making the commands invisible.Solution
role_admin.pyfunctionality intoadmin.pyas singleAdminCogadmingroup androlesubgroup as class attributes inside the cogrole_admin.pyand its test file__main__.py(no longer needed)This matches how
/ctfcommands work and follows the py-cord example.Changes
src/cmds/core/admin.py- Combined admin + role admin functionalitysrc/cmds/core/role_admin.py- Deletedtests/src/cmds/core/test_role_admin.py- Deleted (tests included in admin tests)Test Plan
/admin rolecommands appear in Discord/admin role listshows seeded roles