#How to load Cogs in discord v2 (pycord)
1 messages · Page 1 of 1 (latest)
Hey @oblique mauve just use
client.load_extensions("CogName"). Thats not a async function.
thank you for replying , i modified the code
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
# cut off the .py from the file name
await client.load_extension(f"cogs.{filename[:-3]}")```
i got no error but ```@commands.Cog.listener()``` not responding
I'm sorry i just moved from main discord to pycord , so facing some issue 😅
I have almost the same code you may try it:
for file in os.listdir("./cogs"):
if file.endswith(".py"):
try:
client.load_extension(f"cogs.{file[:-3]}")
except Exception as e:
print(f"Cog {file[:-3]} failed loading:\n{e}")```
checking
eg also don't use await with load_extension
Ah yea thats still in your code
you dont need to await load_extension