I'm trying to load my cog through 3 folders, however, it doesnt seem to work

33 Views Asked by At

My directory goes like this: bob (folder) -> main (folder) -> commands (folder) -> test (folder) test.py (file)

This code seems to work fine

async def load1():
    for filename in os.listdir("main/commands"):
        if filename.endswith(".py"):
            await client.load_extension(f"commands.{filename[:-3]}")

but i want my code to go through another folder like this

async def load1():
    for filename in os.listdir("main/commands/testfolder"):
        if filename.endswith(".py"):
            await client.load_extension(f"testfolder.{filename[:-3]}")

when i run this, it gives me the error: ModuleNotFoundError: No module named 'testfolder'

Basically, i want my code to load folders which would contain something like this commandFolder -> command.py, command.json, command.txt

Is this possible?

0

There are 0 best solutions below