DatabaseManager
Handles the internal data persistence for queues, sessions, and player states. Supports both 'memory' and 'local' (file-based) storage.
The DatabaseManager is responsible for abstracting the storage layer. Moonlink.js uses this to persist player queues and session data, allowing for features like auto-resume even after a bot restart (if using the local provider).
Properties
Database Properties
Internal state of the database manager.
Configuration
The active database provider instance.
Methods
initialize()
initialize()#
→Promise<void>Initializes the underlying database provider (e.g., opens the file connection or connects to the server).
Note: Called automatically by manager.init().
get(key)
Retrieves a value from the database.
The key to retrieve.
set(key, value)
set(key, value)#
→Promise<void>Saves a value to the database.
The key to store.
The value to store.
has(key)
Checks if a key exists in the database.
The key to check.
remove(key)
remove(key)#
→Promise<boolean>Deletes a specific key from the database.
The key to remove.
keys(pattern)
keys(pattern)#
→Promise<string[]>Retrieves all keys, optionally matching a pattern.
Optional regex-like pattern.
clear()
shutdown()
shutdown()#
→Promise<void>Gracefully closes the database connection.