-
Notifications
You must be signed in to change notification settings - Fork 2
Database configuration
Some extensions require data to be persisted, meaning it is preserved between reboots and/or shared with other instances. These extensions typically have a database
configuration option that tells the bot how to persist data.
Note that extensions each have their own individual database definition and do not necessarily need to use the same underlying database.
Data will not be persisted and will remain transiently in-memory only. This is often the default when no explicit database
options are supplied.
Use a simple JSON file to persist data to disk locally. Extensions will generally maintain an in-memory cache to avoid having to read/write to/from the file on every operation.
Not recommended for bots in many guilds or for extensions with an unbounded and/or rapidly-increasing amount of persistent data.
-
path
: the path to the JSON file to read/write to/from. -
no_init
: set to disable automatic creation of the JSON file when it does not already exist. The default behaviour is to create the JSON file (and all parent directories) automatically when they are needed. -
indent
: set to configure the level of indentation to use when writing JSON to file. Only recommended in cases where humans may need to look at the file, such as during development of the extension. The default behaviour is to not apply any indentation so that the JSON file is more compact.
Here's a minimal example, which only specifies a path to a JSON file:
{
"extensions": [
{
"name": "commanderbot.ext.faq",
"options": {
"database": "path/to/some/file.json"
}
}
]
}
This effectively sets the path
and uses default values for everything else. The json
database type is decided based on the path structure and file extension.
Here's a more complete and explicit example that disables file creation and sets the indentation level for human readability:
{
"extensions": [
{
"name": "commanderbot.ext.faq",
"options": {
"database": {
"type": "json",
"path": "data/faq.json",
"indent": 2
}
}
}
]
}