mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-23 03:08:01 -05:00
[V3 Config] Allow users to directly specify a cog name with config (#1339)
This commit is contained in:
@@ -80,15 +80,19 @@ def _base_data_path() -> Path:
|
||||
return Path(path).resolve()
|
||||
|
||||
|
||||
def cog_data_path(cog_instance=None) -> Path:
|
||||
def cog_data_path(cog_instance=None, raw_name: str=None) -> Path:
|
||||
"""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.
|
||||
|
||||
Either ``cog_instance`` or ``raw_name`` will be used, not both.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
cog_instance
|
||||
The instance of the cog you wish to get a data path for.
|
||||
raw_name : str
|
||||
The name of the cog to get a data path for.
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -103,7 +107,10 @@ def cog_data_path(cog_instance=None) -> Path:
|
||||
raise RuntimeError("You must load the basic config before you"
|
||||
" can get the cog data path.") from e
|
||||
cog_path = base_data_path / basic_config['COG_PATH_APPEND']
|
||||
if cog_instance:
|
||||
|
||||
if raw_name is not None:
|
||||
cog_path = cog_path / raw_name
|
||||
elif cog_instance is not None:
|
||||
cog_path = cog_path / cog_instance.__class__.__name__
|
||||
cog_path.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user