Data Manager¶
Data manager is a module that handles all the information necessary to bootstrap the bot into a state where more abstract data management systems can take over.
-
redbot.core.data_manager.
load_basic_configuration
(instance_name_: str)[source]¶ Loads the basic bootstrap configuration necessary for
Config
to know where to store or look for data.Important
It is necessary to call this function BEFORE getting any
Config
objects!Parameters: instance_name (str) – The instance name given by CLI argument and created during redbot setup.
-
redbot.core.data_manager.
cog_data_path
(cog_instance=None) → pathlib.Path[source]¶ Gets the base cog data path. If you want to get the folder with which to store your own cog’s data please pass in an instance of your cog class.
Parameters: cog_instance – The instance of the cog you wish to get a data path for. Returns: If cog_instance
is provided it will return a path to a folder dedicated to a given cog. Otherwise it will return a path to the folder that contains data for all cogs.Return type: pathlib.Path
-
redbot.core.data_manager.
load_bundled_data
(cog_instance, init_location: str)[source]¶ This function copies (and overwrites) data from the
data/
folder of the installed cog.Important
This function MUST be called from the
setup()
function of your cog.Examples
>>> from redbot.core import data_manager >>> >>> def setup(bot): >>> cog = MyCog() >>> data_manager.load_bundled_data(cog, __file__) >>> bot.add_cog(cog)
Parameters: - cog_instance – An instance of your cog class.
- init_location (str) – The
__file__
attribute of the file where yoursetup()
function exists.
-
redbot.core.data_manager.
bundled_data_path
(cog_instance) → pathlib.Path[source]¶ The “data” directory that has been copied from installed cogs.
Important
You should NEVER write to this directory. Data manager will overwrite files in this directory each time
load_bundled_data
is called. You should instead write to the directory provided bycog_data_path
.Parameters: cog_instance – Returns: Path object to the bundled data folder. Return type: pathlib.Path Raises: FileNotFoundError
– If no bundled data folder exists or if it hasn’t been loaded yet.