Skip to content

Pull Request: Implementation of Sharding, Middleware, and Development Enhancements - #7

Open
ramkrishna-js wants to merge 1 commit into
ethical-programmer:mainfrom
ramkrishna-js:main
Open

Pull Request: Implementation of Sharding, Middleware, and Development Enhancements#7
ramkrishna-js wants to merge 1 commit into
ethical-programmer:mainfrom
ramkrishna-js:main

Conversation

@ramkrishna-js

Copy link
Copy Markdown

Overview

This pull request introduces several architectural improvements to the create-discobase framework, focusing on scalability, extensibility, and developer productivity. Additionally, it addresses critical stability issues identified in the project initialization process and event handling logic.

Feature Implementations

Middleware System

  • Implemented a modular middleware architecture within src/middleware/.
  • This system allows for global pre-execution logic, such as authentication checks, maintenance mode toggles, or request logging, to be executed before any slash command.
  • Integrated the middleware loop into the core interactionCreate.js handler.

Sharding Support

  • Integrated optional sharding capabilities using the Discord.js ShardingManager.
  • The project initialization script (setup.mjs) has been updated to include a configuration prompt for sharding.
  • If selected, the system generates a sharding.js entry point designed for high-concurrency environments.

TypeScript and IDE Integration

  • Added a jsconfig.json file utilizing NodeNext module resolution.
  • This enhancement provides improved IntelliSense, type checking, and documentation tooltips within supported editors (e.g., VS Code) for JavaScript-based bot development.
  • Standardized prompt return types within the setup script to resolve implicit type conversion warnings.

Documentation Updates

  • Revised the README.md to document the new Middleware and Sharding systems.
  • Included technical specifications and implementation examples for the newly added features.

Bug Fixes

Project Initialization Stability

  • Resolved a critical ERR_FS_CP_EINVAL error in setup.mjs. The script now correctly identifies and excludes the destination directory during recursive copy operations, preventing infinite recursion when creating a project within a tracked directory.

Handler Optimization

  • Corrected a logic error in functionHandler.js that caused handler files to be loaded multiple times, which previously resulted in duplicate file watchers and increased resource consumption.

Event Handler Refactoring

  • Updated handelEvents.js to utilize client.removeListener instead of removeAllListeners. This change ensures that during hot-reloads, only the specific file-associated listener is replaced, preserving unrelated event listeners.

Testing Procedures

Project Generation

  • Execute node setup.mjs and verify the sharding configuration prompt.
  • Confirm that the resulting project structure contains the expected middleware and sharding files based on user selection.

Execution Logic

  • Verify that middleware functions in src/middleware/index.js execute correctly and can successfully halt command execution when returning false.
  • Launch the bot using node sharding.js (if enabled) to confirm proper shard spawning.

Development Environment

  • Verify that IntelliSense is active in src/commands/ by inspecting the properties of the interaction and client objects.

Checklist

  • Code adheres to the established project style guidelines.
  • Comprehensive self-review performed.
  • Technical documentation and inline comments updated.
  • All identified stability issues resolved.
  • No regressions introduced in core command handling.

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