mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -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:
parent
f71aa9dd21
commit
f6d27a0f43
@ -89,6 +89,9 @@ def parse_cli_flags(args):
|
|||||||
parser.add_argument("--no-cogs",
|
parser.add_argument("--no-cogs",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Starts Red with no cogs loaded, only core")
|
help="Starts Red with no cogs loaded, only core")
|
||||||
|
parser.add_argument("--load-cogs", type=str, nargs="*",
|
||||||
|
help="Force loading specified cogs from the installed packages. "
|
||||||
|
"Can be used with the --no-cogs flag to load these cogs exclusively.")
|
||||||
parser.add_argument("--self-bot",
|
parser.add_argument("--self-bot",
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="Specifies if Red should log in as selfbot")
|
help="Specifies if Red should log in as selfbot")
|
||||||
@ -126,3 +129,4 @@ def parse_cli_flags(args):
|
|||||||
args.prefix = []
|
args.prefix = []
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|||||||
@ -61,12 +61,17 @@ def init_events(bot, cli_flags):
|
|||||||
return
|
return
|
||||||
|
|
||||||
bot.uptime = datetime.datetime.utcnow()
|
bot.uptime = datetime.datetime.utcnow()
|
||||||
|
packages = []
|
||||||
|
|
||||||
if cli_flags.no_cogs is False:
|
if cli_flags.no_cogs is False:
|
||||||
print("Loading packages...")
|
packages.extend(await bot.db.packages())
|
||||||
failed = []
|
|
||||||
packages = 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:
|
for package in packages:
|
||||||
try:
|
try:
|
||||||
spec = await bot.cog_mgr.find_cog(package)
|
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),
|
log.exception("Failed to load package {}".format(package),
|
||||||
exc_info=e)
|
exc_info=e)
|
||||||
await bot.remove_loaded_package(package)
|
await bot.remove_loaded_package(package)
|
||||||
|
to_remove.append(package)
|
||||||
|
for package in to_remove:
|
||||||
|
packages.remove(package)
|
||||||
if packages:
|
if packages:
|
||||||
print("Loaded packages: " + ", ".join(packages))
|
print("Loaded packages: " + ", ".join(packages))
|
||||||
|
|
||||||
@ -277,3 +285,4 @@ def _get_startup_screen_specs():
|
|||||||
ascii_border = False
|
ascii_border = False
|
||||||
|
|
||||||
return on_symbol, off_symbol, ascii_border
|
return on_symbol, off_symbol, ascii_border
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user