CorwinDev / Discord-Bot

Discord Bot with over 400 commands and made for large servers
MIT License
652 stars 599 forks source link

Optimize Server Removal Handling: Database Schema Consolidation #229

Closed xGh0st0X13 closed 3 months ago

xGh0st0X13 commented 5 months ago

This pull request aims to refactor and optimize the code responsible for handling the removal of a bot from a Discord server. The original code contained redundant and repetitive lines for deleting entries from various database schemas associated with a guild. The updated code introduces a more concise and maintainable approach.

Changes Made:

  1. Consolidation of Schemas:

    • Instead of individually importing and deleting entries for each database schema, an array (schemaFiles) has been created to store the names of all schemas.
    • A loop now dynamically imports each schema, reducing redundancy in the code.
  2. Simplified Database Cleanup:

    • The deleteMany operation for each schema is now performed within a loop, eliminating repetitive lines.
    • The loop iterates over the imported schemas, and each schema's deleteMany operation targets entries with the specified Guild.