Rather then load cogs based off of a predefined list, load cogs dynamically with something like
# Loop over every file in the cogs dir
for file in os.listdir(cwd+"/cogs"):
# If the file is a python file and does not start with an _
# assume it is a cog and attempt to load it
if file.endswith(".py") and not file.startswith("_"):
try:
bot.load_extension(f"cogs.{file[:-3]}")
except Exception as e:
logger.error(f"Failed to load cog: {file[:-3]}\n{e}")
Instead of
extensions = ["cogs.docs"]
for ext in extensions:
bot.load_extension(ext)
All files that start with _ are ignored, hence any utility files can be ignored.
This would allow for easier loading during development and also is a helpful move for deploying and reloading remotely. If we set it up to update the code remotely by pulling and cloning master, if anything changes using a dynamic cog loader would suit rather then needing to change the existing list.
Rather then load cogs based off of a predefined list, load cogs dynamically with something like
Instead of
All files that start with _ are ignored, hence any utility files can be ignored.
This would allow for easier loading during development and also is a helpful move for deploying and reloading remotely. If we set it up to update the code remotely by pulling and cloning master, if anything changes using a dynamic cog loader would suit rather then needing to change the existing list.