I'm currently working on a Discord bot and am trying to get the cogs from more than one folder (better order) but I can't get it to work, please help me lol
At the moment I use this system and it works:
for cogpath in os.listdir("cogs"):
if cogpath.endswith(".py"):
client.load_extension(f'cogs.{cogpath[:-3]}')
I tried to expand it with a second field:
for cogpath in os.listdir("cogs/Folder1"):
if cogpath.endswith(".py"):
client.load_extension(f'cogs.{cogpath[:-3]}')
But all I get is this:
Error: Extension 'cogs.MyCog' could not be loaded.
Would be awesome if you could help me. :)
You forgot to load_extension
at the new path
for cogpath in os.listdir("cogs/Folder1"):
if cogpath.endswith(".py"):
client.load_extension(f'cogs.Folder1.{cogpath[:-3]}')
Hope it helps