mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 18:27:59 -05:00
[V3 Parser] Added --load-cogs flag (#1601)
* [V3 Parser] Added --load-cogs flag * Removed old PR data * Removed old PR data * Removed old PR data * Slightly reword help for flag * Stick to convention for checking if sequence is empty * Fix some logic errors * Don't print packages which failed to load
This commit is contained in:
@@ -61,12 +61,17 @@ def init_events(bot, cli_flags):
|
||||
return
|
||||
|
||||
bot.uptime = datetime.datetime.utcnow()
|
||||
packages = []
|
||||
|
||||
if cli_flags.no_cogs is False:
|
||||
print("Loading packages...")
|
||||
failed = []
|
||||
packages = await bot.db.packages()
|
||||
packages.extend(await bot.db.packages())
|
||||
|
||||
if cli_flags.load_cogs:
|
||||
packages.extend(cli_flags.load_cogs)
|
||||
|
||||
if packages:
|
||||
to_remove = []
|
||||
print("Loading packages...")
|
||||
for package in packages:
|
||||
try:
|
||||
spec = await bot.cog_mgr.find_cog(package)
|
||||
@@ -75,6 +80,9 @@ def init_events(bot, cli_flags):
|
||||
log.exception("Failed to load package {}".format(package),
|
||||
exc_info=e)
|
||||
await bot.remove_loaded_package(package)
|
||||
to_remove.append(package)
|
||||
for package in to_remove:
|
||||
packages.remove(package)
|
||||
if packages:
|
||||
print("Loaded packages: " + ", ".join(packages))
|
||||
|
||||
@@ -277,3 +285,4 @@ def _get_startup_screen_specs():
|
||||
ascii_border = False
|
||||
|
||||
return on_symbol, off_symbol, ascii_border
|
||||
|
||||
|
||||
Reference in New Issue
Block a user