Data Manager
Relevant source files
The following files were used as context for generating this wiki page:
The Data Manager handles the bot's filesystem structure and storage configurations. It identifies where the bot stores settings, cog data, and global configuration files. The system manages instance-specific data paths and determines the active storage type, such as JSON or MongoDB, used by the bot's configuration backend.
File System Architecture
The Data Manager organizes data into specific directories based on the instance name and cog requirements. It uses a basic_config dictionary to track the DATA_PATH, which serves as the root for all persistent information.
Path Management
The system identifies the following key paths:
- Data Path: The primary directory for the bot instance's data.
- Metadata File: The configuration file defining instance settings.
- Cog Data Path: Specific subdirectories for individual modules, such as
redbot/cogs/audio.
Sources: redbot/core/core_commands.py:1680-1685, redbot/core/_debuginfo.py:157-158, redbot/cogs/audio/manager.py:126-128
The diagram shows the hierarchical relationship between the root data path and specific cog storage.
Sources: redbot/cogs/audio/manager.py:126-137, redbot/core/_debuginfo.py:158
Storage Configuration
The bot supports multiple storage backends. The storage_type function returns a string indicating the current driver in use.
| Component | Description |
|---|---|
storage_type() | Returns the active storage driver (e.g., JSON). |
instance_name() | Identifies the unique label for the current bot instance. |
config_file | Locates the primary metadata file for the instance. |
Sources: redbot/core/_events.py:108, redbot/core/_debuginfo.py:124-159
End-User Data Management
The bot provides internal mechanisms to handle data deletion requests to comply with privacy standards. The Core cog interfaces with the Config system to delete or disassociate user data when requested.
Deletion Process
When a user or owner triggers a deletion, the bot performs these steps:
- Receives the
user_idand requester type (user,user_strict,discord_deleted_user, orowner). - Iterates through all loaded cogs and modules.
- Invokes the
red_delete_data_for_usermethod in each component. - Returns a result object containing failed cogs or modules.
Sources: redbot/core/core_commands.py:339-350, redbot/core/core_commands.py:440-445
The sequence diagram illustrates the flow of a data deletion request through the bot's core and into individual modules.
Sources: redbot/core/core_commands.py:326-400
Managed Component Storage
Specific cogs like Audio utilize the Data Manager to handle external binaries and configuration templates. The Audio ServerManager uses the cog's data path to manage the Lavalink ecosystem.
Lavalink File Management
The Data Manager provides the environment for:
- Downloading Jars: Stores
Lavalink.jarin theAudiocog data directory. - Configuration Generation: Creates
application.ymlbased on bot settings. - Java Execution: Runs the server within the instance's directory context.
Sources: redbot/cogs/audio/manager.py:126-137, redbot/cogs/audio/manager.py:157-160
Technical Summary
The Data Manager ensures that Red bot remains modular and instance-independent by centralizing path resolution and storage abstraction. It enables features like data privacy (Forget Me), debug information reporting, and managed external services by providing a consistent interface to the underlying filesystem and database.
Sources: redbot/core/core_commands.py:1680-1685, redbot/core/_debuginfo.py:153-159