refactor: extract duplicated patterns into shared helpers#20
Conversation
Create 4 shared helpers (safeErrorReply, requireOwner, sendToMainChannel, updateGuildPremiumStatus) to replace copy-pasted patterns across 28 files, removing ~200 lines of duplicated code while preserving identical behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (32)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
…ragglers to withCommandLogging (#22) * refactor: extract buildBrandedEmbed + logEntitlementEvent, migrate stragglers to withCommandLogging Follow-up duplication audit after #20. Consolidates remaining copy-paste: - New src/utils/embedHelpers.ts with buildBrandedEmbed, BRAND_COLOR, BRAND_FOOTER. Single source of truth for brand color (0xfadb7f) and footer; previously duplicated across 9 callsites. - New logEntitlementEvent in src/utils/entitlementHelpers.ts. Entitlement Create/Delete/Update events now share one logging shape. - Migrated 7 commands from hand-rolled try/catch + executing/error logging to withCommandLogging: help, about, invite, changelog, admin/quote/create, admin/quote/remove, admin/activity/create, admin/activity/remove, admin/suggestion/stats, setup/channel. Fixes setup/channel logging the wrong command name on success/error. - Refactored premium-cmd, setup/schedule, quoteHelpers.buildMotivationEmbed, premium.buildPremiumUpsell, admin/suggestion/stats, changelog, about, admin/quote/create embed scaffolding through buildBrandedEmbed. Tests: 244 pass, 0 fail. typecheck + lint clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(tests): isolate quoteHelpers from cross-file mock leakage CI surfaced 3 quoteHelpers test failures: the bun:test mock.module registry is process-global, so tests/commands/quote.test.ts and tests/worker/sendMotivation.test.ts mocking src/utils/quoteHelpers.js poisoned tests/utils/quoteHelpers.test.ts whenever bun's test discovery walked those files first. Same root cause #21 fought with readyDeps / commandRegistry shims. Apply the same shim pattern: - New src/commands/quoteDeps.ts re-exports buildMotivationEmbed, getRandomMotivationQuote, resolveQuoteAuthor. src/commands/quote.ts imports from the shim. quote.test.ts mocks the shim, not the real module. - New src/worker/jobs/sendMotivationDeps.ts mirrors the same shim for the worker job. sendMotivation.test.ts mocks the shim. Local: 244 pass, 0 fail. typecheck clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
safeErrorReply,requireOwner,sendToMainChannel,updateGuildPremiumStatus) to replace copy-pasted patternsTest plan
bun run typecheckpassesbun test— 228 tests, 0 failuresbun run lintpasses🤖 Generated with Claude Code