Skip to content

[Reviewed] feat: Add cooldown tracking with Collection (Item 5) - NEEDS REVISION#51

Open
messiawrq-spec wants to merge 1 commit into
IN3PIRE:mainfrom
messiawrq-spec:feat/cooldown-system
Open

[Reviewed] feat: Add cooldown tracking with Collection (Item 5) - NEEDS REVISION#51
messiawrq-spec wants to merge 1 commit into
IN3PIRE:mainfrom
messiawrq-spec:feat/cooldown-system

Conversation

@messiawrq-spec
Copy link
Copy Markdown
Contributor

Claims and resolves Item #5 from Issue #40.

Added a comprehensive cooldown manager directly inside interactionCreate.js. It utilizes standard Discord.js Collection objects to track users per-command, honoring custom command.cooldown parameters and protecting against spam.

Resolves Item IN3PIRE#5 from Issue IN3PIRE#40. Added a cooldown `Collection` logic into `interactionCreate.js` to prevent command spam based on a configured `command.cooldown` (defaults to 3s).
@TrivCodez TrivCodez changed the title feat: Implement command cooldown system (Item 5) [Reviewed] feat: Add cooldown tracking with Collection (Item 5) - NEEDS REVISION May 15, 2026
Copy link
Copy Markdown
Contributor

@TrivCodez TrivCodez left a comment

Choose a reason for hiding this comment

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

Summary

Adds in-memory cooldown tracking with Discord.js Collection for per-command rate limiting.

🔴 Critical Issues

File Line Severity Issue Fix
src/events/interactionCreate.js 4-26 CRITICAL Duplicate cooldown logic - This PR implements cooldown directly but the file already imports and uses checkCooldown/setCooldown from ../utils/cooldown Remove lines 14-33 entirely - the existing checkCooldown call at line 35 already handles this

🟡 Warnings

File Line Severity Issue Fix
src/events/interactionCreate.js 4-5 High Imports Collection and creates cooldowns but duplicates existing utility Delete import and use existing cooldown module
src/events/interactionCreate.js 20 Medium Hardcoded defaultCooldownDuration = 3 - magic number Move to config or command-level setting
src/events/interactionCreate.js 37 Low Cooldown check happens AFTER this implementation runs (line 35) causing redundant logic Remove duplicate implementation

Analysis

This PR creates conflicting cooldown implementations:

  1. Lines 14-33: New in-memory cooldown with Collection
  2. Line 35: Calls existing checkCooldown() from utility module

Problem: Both will run, potentially causing:

  • Double cooldown enforcement
  • Memory leak (Collection grows unbounded)
  • Confusing behavior for command authors

🟢 Suggestions

Option 1 (Recommended): Remove this PR entirely - existing cooldown.js handles it
Option 2: Replace cooldown.js with this implementation if Collection-based approach is preferred
Option 3: Merge both approaches - use Collection for storage but keep utility functions for logic

✅ Good

  • Clean Discord timestamp format for remaining time
  • Proper cleanup with setTimeout
  • Per-command customization support

Needs revision - Must resolve duplicate cooldown logic before merging. Recommend removing lines 14-33 and keeping existing checkCooldown/setCooldown calls.

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.

2 participants