How polowiper/dokkanwtbot works
Main Components
• Discord Bot Client: Represented by main.py, which is the entry point that connects to Discord. It loads the command “cogs” (e.g., bulk.py, compare.py, help.py, etc.) to handle various bot commands.
• Command Modules (“Cogs”): The cogs/ directory consists of separate Python files that encapsulate specific commands or features (like leaderboard, ranking, etc.). They are modular pieces helping maintain the bot’s functionality.
• API Integration & Data Acquisition: Scripts like api.py and fetch_and_save.py are responsible for connecting to the external Dokkan Battle API. They fetch and update data from the API source.
• Data Management & Storage: The final_data folder contains subdirectories (by usernames/identifiers) that appear to store processed user data. Scripts such as update_data.py and update_db.py are likely used to refresh or handle this data.
• Configuration & Utilities: Files like config.py, config.json, and dependencies.txt store configuration settings (like BOT_TOKEN, API_TOKEN, and other parameters), while other utility scripts (like cli_main.py, manual_update.py, render.py, and final_render.py) help in bot operations and potentially rendering outputs.
• External Data Source: Although not part of the repository, the external Dokkan APi (via T6) is a key element in the system as it supplies the dynamic data the bot uses.
Relationships and Interactions
• Data Flow: Start with an external data source (Dokkan Battle API) that provides game data. The fetch_and_save.py script pulls data, and the update_data.py/update_db.py scripts process and update this data into the stored files in final_data.
• Command Execution: The main.py loads various cogs. When a Discord user issues a command, the appropriate cog (command module) is activated, and it uses the stored data (or possibly fresh API data) to serve responses (e.g., leaderboard, user comparisons).
• Configuration: config.py (and config.json) provide settings and credentials for both the Discord bot and API interactions. These settings are used across the client and data-fetching processes.
Architectural Patterns & Design Principles
• Modularity: The use of a “cogs” directory clearly indicates a modular design where each command is separated into its own file for better maintainability.
• Separation of Concerns: Different scripts handle distinct functionalities (e.g., data fetching vs. bot command handling vs. configuration).
• Data Persistence: The directory structure under final_data shows that user data is persisted in a structured file system layout rather than a dedicated database.
• Config-driven Behavior: Configuration files (config.py, config.json, dependencies.txt) drive runtime behavior, ensuring flexibility in deployment and operation.
Relevant Technologies & Frameworks
• Python for the overall application.
• Discord API libraries (such as discord.py, if used) to manage bot connections and interactions.
• External API integration for Dokkan Battle data (via the T6 API).
• Pip for dependency management.
• File-based data storage (using the final_data folder structure).