Skip to content

fix: combine role_admin into admin cog for proper subgroup handling#182

Merged
dimoschi merged 2 commits intomainfrom
feature/dynamic-roles-db-combined-admin
Apr 6, 2026
Merged

fix: combine role_admin into admin cog for proper subgroup handling#182
dimoschi merged 2 commits intomainfrom
feature/dynamic-roles-db-combined-admin

Conversation

@dimoschi
Copy link
Copy Markdown
Contributor

@dimoschi dimoschi commented Apr 6, 2026

Summary

Fixes the /admin role commands not appearing in Discord by combining role_admin.py into admin.py as a single cog. This follows py-cord's documented pattern for subgroups.

Problem

The /admin group was defined at module level and registered via bot.add_application_command(), while the role subgroup was created via admin.create_subgroup() in a different file. This caused py-cord to not properly set the cog attribute on the subgroup, making the commands invisible.

Solution

  • Merge role_admin.py functionality into admin.py as single AdminCog
  • Define both admin group and role subgroup as class attributes inside the cog
  • Delete role_admin.py and its test file
  • Revert special loading order in __main__.py (no longer needed)

This matches how /ctf commands work and follows the py-cord example.

Changes

  • src/cmds/core/admin.py - Combined admin + role admin functionality
  • src/cmds/core/role_admin.py - Deleted
  • tests/src/cmds/core/test_role_admin.py - Deleted (tests included in admin tests)

Test Plan

  • All 250 tests pass
  • Deploy to staging and verify /admin role commands appear in Discord
  • Test /admin role list shows seeded roles

- 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.
@dimoschi dimoschi requested a review from makelarisjr as a code owner April 6, 2026 14:01
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.73%. Comparing base (2aff2ef) to head (03196cd).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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
@dimoschi dimoschi merged commit 361201d into main Apr 6, 2026
7 checks passed
@dimoschi dimoschi deleted the feature/dynamic-roles-db-combined-admin branch April 6, 2026 14:43
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.

1 participant