☑️ Module permissions
The framework implements a permission system for modules, allowing them to request access to specific features or resources. These permissions are declared in the module's config.yaml
(or fallback info.yaml
) file under the permissions key.
When a user attempts to install or update a module, the requested permissions are displayed, and confirmation might be required depending on the system configuration. If a required permission is not met (e.g., require_db
when the database is disabled), the module loading might be skipped.
Permissions are defined in base.module.Permissions
. Currently available permissions:
use_db: Indicates the module uses the database, but can potentially function without it if the database is disabled in the bot's main configuration (
config.enable_db = false
). If DB is enabled, the module instance will receive a Database object in its self.db attribute after initialization.require_db: Declares a strict dependency on the database. If the database is disabled in the bot's configuration, the module will not be loaded. If DB is enabled,
self.db
will be populated.use_loader: Grants the module access to the
ModuleLoader
instance via theself.loader
attribute.WARNING
This is a powerful permission, as the
ModuleLoader
provides methods to load, unload, install, update, and manage other modules and dependencies. Grant this permission only to trusted modules.
Example config.yaml
requesting database access and loader access:
# config.yaml
info:
name: AdvancedModule
author: Dev Team
version: 1.2.0
description: Does advanced stuff requiring DB and module management.
auto_load: true
permissions:
- require_db # Needs the database to function
- use_loader # Needs access to the ModuleLoader API
config:
# ... module specific config ...
WARNING
Ensure you only request permissions that your module genuinely needs.