Skip to content

Revamped the codebase (some bits)#8

Merged
breadddevv merged 1 commit into
mainfrom
revamp/codebase
Jun 7, 2026
Merged

Revamped the codebase (some bits)#8
breadddevv merged 1 commit into
mainfrom
revamp/codebase

Conversation

@breadddevv

@breadddevv breadddevv commented Jun 7, 2026

Copy link
Copy Markdown
Member

🚀 Summary

  • Refactored command execution pipeline with dedicated validation helpers
  • Significantly improved role service error handling and recovery
  • Enhanced UI consistency with new color system
  • Strengthened permission and hierarchy validation

✨ Features

  • New SystemColors enum (main: 0xFF48B6) for unified UI theming across the application
  • Command validation extracted into private helpers (validateCommand(), validatePermissions(), applyCooldown()) enabling better error handling and code reusability
  • Owner-only command rejections now use v2 components with red accent color for improved UX

🐛 Fixes

  • Added comprehensive error handling to all role operations (assign, remove, create, delete, update)
  • Custom role creation now validates bot permissions and role hierarchy before attempting to create
  • Role deletion safely handles failures and cleans up Discord role if member assignment fails
  • Hardened guild member update logging with optional chaining for safer null handling

♻️ Improvements

  • Role service operations now provide detailed error logging and user-facing error messages
  • Custom role assignment includes fallback DM notifications on permission failures
  • Setup command feedback now uses v2 components with system color scheme
  • Boost greeting embeds enhanced with footer text

⚠️ Breaking Changes

  • createCustomRole() return type changed from Promise<Role> to Promise<Role | null> (returns null on permission/hierarchy failures)
  • deleteCustomRole() return type changed from Promise<void> to Promise<boolean> (indicates success/failure)
  • Command file loader filter logic updated to handle test file exclusion

📦 Chores

  • Removed unused imports across multiple files (ChatInputCommandInteraction, ActivityType, Client)
  • Code formatting improvements for embed and container construction

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR refactors command framework validation/cooldown handling into private helpers, hardens role service with error handling and permission checks, improves event logging safety with optional chaining, consolidates system colors, and excludes test files from command loading.

Changes

Robustness and Framework Refactoring

Layer / File(s) Summary
Command validation and cooldown extraction
src/base/classes/command.ts
Command.run() delegates pre-execution checks to validateCommand() and validatePermissions(), and cooldown enforcement to applyCooldown(). The _cooldowns field is now readonly. The ownerOnly denial uses a component-based ephemeral reply with ContainerBuilder. Note: applyCooldown() invokes this.execute(), and run() also calls this.execute() in its try/catch.
System colors palette and component-based UI responses
src/libs/colors.ts, src/commands/setup.ts
New SystemColors.main (0xFF48B6) enum constant. setup.ts now uses ContainerBuilder with SystemColors.main accent and text display component for the "already configured" ephemeral reply.
Role service error handling and permission validation
src/services/roleService.ts
assignLevelRoles and removeAllLevelRoles wrap role mutations in try/catch with logging. createCustomRole validates ManageRoles permission, checks role position, wraps creation and assignment in error handling (rolls back on failure), and returns null instead of throwing. deleteCustomRole returns boolean and handles deletion errors. updateCustomRole wraps edits in try/catch, returns null on failure, and DMs users on permission errors.
Event handler logging safety and formatting improvements
src/events/guildMemberUpdate.ts, src/events/clientReady.ts, src/events/roleCleanup.ts
guildMemberUpdate uses optional chaining (oldMember?.id) for safer error logging and adds footer text to boost greeting embed. Multi-line reformatting of embed and message constructions in boost flows. clientReady removes unused ActivityType, roleCleanup tidies imports.
Command file loading filter and import cleanup
src/libs/loadCommands.ts, src/commands/example_all.test.ts, src/commands/info.ts, src/commands/role.ts
loadCommands() now excludes .test.ts and .test.js files from command registration. Unused ChatInputCommandInteraction and other discord.js symbols removed from test and command file imports.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • teamboostify/boostify#7: Both PRs modify the src/events/guildMemberUpdate.ts event handler, introducing related changes to embed formatting and boost flow handling.

Poem

🐰 Commands now run with style so bright,
Helpers extract the logic just right,
Roles check permissions before they proceed,
Colors paint answers to every need,
Error-safe paths where failures are free!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Revamped the codebase (some bits)' is vague and generic, using non-descriptive language like 'some bits' that fails to convey meaningful information about the substantial changes across multiple files. Use a more specific title that highlights the main changes, such as 'Refactor command validation and cooldown handling' or 'Extract validation logic and update role service error handling'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch revamp/codebase

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@breadddevv breadddevv merged commit 117b03c into main Jun 7, 2026
3 of 4 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jun 7, 2026
Merged
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