mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 02:16:09 -05:00
More privatization, and some error helpers (#2976)
* More privatization, and some error helpers This makes a lot more things private. Continued from #2967, fixes #2984 Adds public methods for various things. Below is a brief summary of things available elsewhere, though this particular set of changes may warrant a detailed section in the release notes. - bot.db.locale -> redbot.core.i18n.get_locale - Note: This one already existed. - bot.db.help -> redbot.core.commands.help.HelpSettings - bot db whitelist/blaclist? -> bot.allowed_by_whitelist_blacklist - This has also been made a single cannonical function for this purpose including check usage - bot color? -> bot.get_embed_color/bot.get_embed_colour - bot.id.api_tokens? -> - bot.get_shared_api_tokens - bot.set_shared_api_tokens - bot.remove_shared_api_tokens -bot.db.prefix -> bot.get_valid_prefixes - (Note: This is a wrapper around bot.get_prefix) Other changes include - removing `bot.counter` as it was never used anywhere - Adding properties with helpful error messages for moved and renamed things - making bot.uptime a property with an error on set - adding a migration to the bot config for shared_api_tokens * Remove overly encompassing message redaction, eval is a risk, dont run in dev if you cant manage it * address Flame's feedback * rephrase example * changelog extras * You saw nothing
This commit is contained in:
@@ -317,7 +317,7 @@ class CogManagerUI(commands.Cog):
|
||||
"""
|
||||
Lists current cog paths in order of priority.
|
||||
"""
|
||||
cog_mgr = ctx.bot.cog_mgr
|
||||
cog_mgr = ctx.bot._cog_mgr
|
||||
install_path = await cog_mgr.install_path()
|
||||
core_path = cog_mgr.CORE_PATH
|
||||
cog_paths = await cog_mgr.user_defined_paths()
|
||||
@@ -344,7 +344,7 @@ class CogManagerUI(commands.Cog):
|
||||
return
|
||||
|
||||
try:
|
||||
await ctx.bot.cog_mgr.add_path(path)
|
||||
await ctx.bot._cog_mgr.add_path(path)
|
||||
except ValueError as e:
|
||||
await ctx.send(str(e))
|
||||
else:
|
||||
@@ -362,14 +362,14 @@ class CogManagerUI(commands.Cog):
|
||||
await ctx.send(_("Path numbers must be positive."))
|
||||
return
|
||||
|
||||
cog_paths = await ctx.bot.cog_mgr.user_defined_paths()
|
||||
cog_paths = await ctx.bot._cog_mgr.user_defined_paths()
|
||||
try:
|
||||
to_remove = cog_paths.pop(path_number)
|
||||
except IndexError:
|
||||
await ctx.send(_("That is an invalid path number."))
|
||||
return
|
||||
|
||||
await ctx.bot.cog_mgr.remove_path(to_remove)
|
||||
await ctx.bot._cog_mgr.remove_path(to_remove)
|
||||
await ctx.send(_("Path successfully removed."))
|
||||
|
||||
@commands.command()
|
||||
@@ -385,7 +385,7 @@ class CogManagerUI(commands.Cog):
|
||||
await ctx.send(_("Path numbers must be positive."))
|
||||
return
|
||||
|
||||
all_paths = await ctx.bot.cog_mgr.user_defined_paths()
|
||||
all_paths = await ctx.bot._cog_mgr.user_defined_paths()
|
||||
try:
|
||||
to_move = all_paths.pop(from_)
|
||||
except IndexError:
|
||||
@@ -398,7 +398,7 @@ class CogManagerUI(commands.Cog):
|
||||
await ctx.send(_("Invalid 'to' index."))
|
||||
return
|
||||
|
||||
await ctx.bot.cog_mgr.set_paths(all_paths)
|
||||
await ctx.bot._cog_mgr.set_paths(all_paths)
|
||||
await ctx.send(_("Paths reordered."))
|
||||
|
||||
@commands.command()
|
||||
@@ -413,14 +413,14 @@ class CogManagerUI(commands.Cog):
|
||||
"""
|
||||
if path:
|
||||
if not path.is_absolute():
|
||||
path = (ctx.bot.main_dir / path).resolve()
|
||||
path = (ctx.bot._main_dir / path).resolve()
|
||||
try:
|
||||
await ctx.bot.cog_mgr.set_install_path(path)
|
||||
await ctx.bot._cog_mgr.set_install_path(path)
|
||||
except ValueError:
|
||||
await ctx.send(_("That path does not exist."))
|
||||
return
|
||||
|
||||
install_path = await ctx.bot.cog_mgr.install_path()
|
||||
install_path = await ctx.bot._cog_mgr.install_path()
|
||||
await ctx.send(
|
||||
_("The bot will install new cogs to the `{}` directory.").format(install_path)
|
||||
)
|
||||
@@ -433,7 +433,7 @@ class CogManagerUI(commands.Cog):
|
||||
"""
|
||||
loaded = set(ctx.bot.extensions.keys())
|
||||
|
||||
all_cogs = set(await ctx.bot.cog_mgr.available_modules())
|
||||
all_cogs = set(await ctx.bot._cog_mgr.available_modules())
|
||||
|
||||
unloaded = all_cogs - loaded
|
||||
|
||||
|
||||
Reference in New Issue
Block a user