robo.js icon indicating copy to clipboard operation
robo.js copied to clipboard

@robojs/cooldown - Cooldowns & Rate-Limiting Plugin Implementation

Open sorabhlahoti opened this issue 2 months ago • 5 comments

Overview

This PR introduces the initial implementation structure for the @robojs/cooldown plugin as requested in issue #448. This plugin provides comprehensive cooldown and rate-limiting functionality for Robo.js Discord bot commands.

What's Included

This initial commit establishes the foundational structure:

Files Added:

  • package.json - Package configuration with dependencies, scripts, and metadata
  • README.md - Comprehensive documentation covering features, installation, usage examples, and API reference
  • tsconfig.json - TypeScript configuration for ES2022 module compilation
  • src/index.ts - Main entry point with exports for middleware, cooldown manager functions, and type definitions

Features (as documented):

  • 🕐 Flexible cooldown durations per command
  • 👥 Multi-scope support (user, channel, guild, global)
  • ⚡ Easy integration via middleware pattern
  • 🔧 Configurable error messages and bypass roles
  • 📊 Built-in management commands and API endpoints

Implementation Status

✅ Package structure established ✅ Documentation complete ✅ Entry point defined

⚠️ Still Required: The complete TypeScript implementation files need to be added:

  • src/middleware/index.ts - Middleware implementation for automatic cooldown application
  • src/lib/cooldown-manager.ts - Core cooldown management logic (applyCooldown, getCooldown, setCooldown, resetCooldown, clearAllCooldowns)
  • src/lib/types.ts - Type definitions (CooldownConfig, CooldownScope, CooldownResult)
  • src/commands/ - Built-in slash commands (/cooldown check, reset, list)
  • src/api/ - API endpoints for @robojs/server integration
  • src/lib/storage.ts - Cooldown data storage implementation

Next Steps

The next PR will add the complete TypeScript implementation files to make this plugin fully functional. This structural foundation ensures the plugin follows Robo.js conventions and provides a clear development roadmap.

Related Issue

Closes #448

sorabhlahoti avatar Oct 06 '25 13:10 sorabhlahoti