Hello everyone, I have the following code:
for folder in os.listdir('./cogs'):
for module in os.listdir(f'./cogs/{folder}'):
for category in os.listdir(f'./cogs/{folder}/{module}'):
for filename in os.listdir(f'./cogs/{folder}/{module}/{category}'):
try:
if filename.endswith('.py'):
bot.load_extension(f'cogs.{folder}.{module}.{category}.{filename[:-3]}')
except Exception as e:
print(f'Error: {e}')
I wrote this code on my own since I didn´t want to always have multiple functions to run different modules e.g.
events.client.ready, events.guild.memberJoin etc.
In my cogs folder I have 2 folders (and more to come), events & cmds, inside those there are more folders which then lead to a .py file.
The problem is that windows gives me an error that this directory name is not correct. Why is that so?

