Skip to content

Added booster fixes & db cleanups#11

Merged
breadddevv merged 2 commits into
mainfrom
fix/boosters
Jun 26, 2026
Merged

Added booster fixes & db cleanups#11
breadddevv merged 2 commits into
mainfrom
fix/boosters

Conversation

@breadddevv

@breadddevv breadddevv commented Jun 26, 2026

Copy link
Copy Markdown
Member

🚀 Summary

  • Added booster cleanup loop loading at startup and a scheduled task to purge stale booster records.
  • Tightened booster command validation and cleanup behavior across check/add/remove flows.
  • Updated ignore rules for generated command/event artifacts and bumped package version.

✨ Features

  • Added loadLoops() startup support to discover and register loop scripts.
  • Added boosterCleanup loop to delete booster entries with zero boostCounts every 60 seconds.

🐛 Fixes

  • booster check now verifies the target member’s active boosting status more accurately.
  • booster add now blocks non-boosting members from being added.
  • booster check now removes stale booster records when boostCounts is zero and reports cleanup failures with a support link.

♻️ Improvements

  • Refactored booster stats output into explicit embed field objects.
  • Expanded component-based reply UI for booster command responses.
  • Improved loop validation/logging for missing runEvery or execute definitions.

⚠️ Breaking Changes

  • None.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@breadddevv, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 44 minutes and 54 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1d196cdf-ff4d-4b00-af99-9fd296649bc2

📥 Commits

Reviewing files that changed from the base of the PR and between 868f4aa and 8b2b74a.

📒 Files selected for processing (3)
  • .gitignore
  • src/commands/booster.ts
  • src/libs/loops.ts
📝 Walkthrough

Walkthrough

The PR adds startup loading for scheduled loop modules, introduces a booster cleanup loop, updates booster command checks and boost registration handling, bumps the package version, and expands .gitignore for additional generated command and event artifacts.

Changes

Booster lifecycle and loop loading

Layer / File(s) Summary
Loop startup and discovery
src/index.ts, src/libs/loops.ts
src/index.ts now awaits loadLoops() after loadCommands(), and loadLoops() discovers loop modules, validates default exports, and schedules each loop with setInterval.
Scheduled booster cleanup
src/loops/boosterCleanup.ts
A new 60-second cleanup loop deletes booster rows whose boostCounts is below 1.
Booster check cleanup path
src/commands/booster.ts
check now fetches the target guild member, derives boost state from premiumSince, requires both booster.active and booster.boostCounts > 0 for the status field, and removes zero-count records with a support-link fallback on failure.
Booster add and stats handling
src/commands/booster.ts
add now requires targetMember?.premiumSince before registerBoost(...) and addBoostCount(...), while remove and stats keep the same replies with formatting-only changes.

Sequence Diagram(s)

Loop startup and scheduled cleanup

sequenceDiagram
  participant Index as src/index.ts
  participant LoadCommands as loadCommands()
  participant LoadLoops as loadLoops()
  participant Interval as setInterval
  participant CleanupLoop as src/loops/boosterCleanup.ts
  participant Prisma as prisma.booster.deleteMany
  Index->>LoadCommands: await
  Index->>LoadLoops: await
  LoadLoops->>CleanupLoop: import default export
  LoadLoops->>Interval: schedule execute() every runEvery seconds
  Interval->>CleanupLoop: execute()
  CleanupLoop->>Prisma: deleteMany where boostCounts < 1
Loading

Booster subcommand flow

sequenceDiagram
  participant Interaction as Discord interaction
  participant Booster as booster command
  participant Fetch as members.fetch(...)
  participant GetBooster as getBooster(...)
  participant RemoveBoost as removeBoost(...)
  participant RegisterBoost as registerBoost(...)
  participant AddBoostCount as addBoostCount(...)
  Interaction->>Booster: run /booster subcommand
  Booster->>Fetch: fetch target member
  alt check
    Booster->>GetBooster: read booster record
    alt boostCounts == 0
      Booster->>RemoveBoost: clean up stored record
    end
  else add
    Booster->>RegisterBoost: register boost
    Booster->>AddBoostCount: increment count
  end
  Booster-->>Interaction: ephemeral reply
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

A bunny hopped through loops at dawn,
And booster crumbs were cleaned up clean.
The buttons clicked, the logs sang on,
New counts grew bright and tidy green.
🐇🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main changes: booster fixes plus database cleanup logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/boosters

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/commands/booster.ts (1)

138-140: 🎯 Functional Correctness | 🟠 Major

Make the initial defer ephemeral.
These editReply({ flags: MessageFlags.Ephemeral ... }) calls won’t change a public deferReply() into an ephemeral response. Set MessageFlags.Ephemeral on the matching deferReply() instead; the same applies to the other editReply calls below.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands/booster.ts` around lines 138 - 140, The Booster command is
trying to make responses ephemeral in editReply, but that cannot change the
visibility after deferReply has already been sent publicly. Update the matching
deferReply call in booster.ts to include MessageFlags.Ephemeral, and remove the
Ephemeral flag from the related editReply calls so the response flow stays
consistent; use the deferReply and editReply paths in the Booster interaction
handler as the main places to adjust.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.gitignore:
- Around line 6-7: The ignore patterns in the .gitignore entries for
src/commands/*.make.ts and src/events/*.make.ts include trailing spaces, so
remove those extra spaces to ensure the patterns match correctly. Update the
.gitignore entries directly and keep the two patterns exact with no whitespace
after them.

In `@src/commands/booster.ts`:
- Around line 183-204: The booster embed in booster.ts currently formats the
“Boosting since” field using member!.premiumSince!, which can throw when the
member is missing or no longer boosting. Update the logic around the embed
creation in the command handler to guard premiumSince before calling getTime(),
and only render the timestamp when a valid premiumSince value exists. If the
member or premiumSince is unavailable, fall back to a safe display value instead
of dereferencing the non-null assertions.
- Around line 147-150: The cleanup call in booster handling is not being
awaited, so rejected errors escape the surrounding try/catch and stale state can
remain. Update the logic in the booster command flow around `removeBoost` to
await the promise before continuing, keeping the existing error handling in
place so failures are caught by this handler.
- Around line 231-238: The boost flow in registerBoost and addBoostCount is
double-counting boosts by applying the increment twice. Update the booster
handling in the booster command so that registerBoost remains responsible for
creating or incrementing the boost record, and avoid calling addBoostCount with
amount afterward when it would add the same boost again; instead, keep a single
source of truth for the boost increment in the addBoost path.

In `@src/libs/loops.ts`:
- Around line 27-28: Wrap the per-file dynamic import in loadLoops so a bad loop
module does not abort startup: the import at fileInfo loading should be inside a
try/catch for each file, log the failure with the file name and error details,
and then continue to the next loop. Keep the per-loop validation and
registration flow in src/libs/loops.ts intact, but ensure one import failure
cannot escape loadLoops and prevent src/index.ts from completing boot.
- Around line 36-45: The async loop in the run function can overlap because
setInterval schedules a new execution before the previous fileInfo.execute()
finishes. Update the looping logic in run and the setInterval scheduling so only
one execution can run at a time, either by adding a running guard around
fileInfo.execute() or by replacing setInterval with self-scheduling setTimeout
after each completion. Keep the logging in logger.error unchanged except for
ensuring the guarded/scheduled flow still reports failures correctly.

---

Outside diff comments:
In `@src/commands/booster.ts`:
- Around line 138-140: The Booster command is trying to make responses ephemeral
in editReply, but that cannot change the visibility after deferReply has already
been sent publicly. Update the matching deferReply call in booster.ts to include
MessageFlags.Ephemeral, and remove the Ephemeral flag from the related editReply
calls so the response flow stays consistent; use the deferReply and editReply
paths in the Booster interaction handler as the main places to adjust.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 268049e0-cbde-4984-b893-d6483f87b5b6

📥 Commits

Reviewing files that changed from the base of the PR and between d716b84 and 868f4aa.

📒 Files selected for processing (6)
  • .gitignore
  • package.json
  • src/commands/booster.ts
  • src/index.ts
  • src/libs/loops.ts
  • src/loops/boosterCleanup.ts

Comment thread .gitignore Outdated
Comment thread src/commands/booster.ts
Comment thread src/commands/booster.ts
Comment thread src/commands/booster.ts Outdated
Comment thread src/libs/loops.ts Outdated
Comment thread src/libs/loops.ts Outdated
@breadddevv breadddevv merged commit 2cac9d8 into main Jun 26, 2026
4 checks passed
@breadddevv breadddevv deleted the fix/boosters branch June 26, 2026 20:42
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