Directory manager for Red’s cogs.
This module allows you to load cogs from multiple directories and even from outside the bot directory. You may also set a directory for downloader to install new cogs to, the default being the
cogs/folder in the root bot directory.
add_path(path: Union[pathlib.Path, str]) → None¶
Add a cog path to current list.
This will ignore duplicates.
Parameters: path (
str) – Path to add.
pathdoes not resolve to an existing directory.
available_modules() → List[str]¶
Finds the names of all available modules to load.
find_cog(name: str) → Optional[_frozen_importlib.ModuleSpec]¶
Find a cog in the list of available paths.
Parameters: name (str) – Name of the cog to find. Returns: A module spec to be used for specialized cog loading, if found. Return type: Optional[importlib.machinery.ModuleSpec]
install_path() → pathlib.Path¶
Get the install path for 3rd party cogs.
Returns: The path to the directory where 3rd party cogs are stored. Return type: pathlib.Path
Re-evaluate modules in the py cache.
This is an alias for an importlib internal and should be called any time that a new module has been installed to a cog directory.
paths() → List[pathlib.Path]¶
Get all currently valid path directories, in order of priority
Returns: A list of paths where cog packages can be found. The install path is highest priority, followed by the user-defined paths, and the core path has the lowest priority. Return type: List[pathlib.Path]
remove_path(path: Union[pathlib.Path, str]) → None¶
Remove a path from the current paths list.
Parameters: path (
str) – Path to remove.
set_install_path(path: pathlib.Path) → pathlib.Path¶
Set the install path for 3rd party cogs.
The bot will not remember your old cog install path which means that all previously installed cogs will no longer be found.
Parameters: path (pathlib.Path) – The new directory for cog installs. Returns: Absolute path to the new install directory. Return type: pathlib.Path Raises:
pathis not an existing directory.
Set the current paths list.
Parameters: paths (
pathlib.Path) – List of paths to set.