简体   繁体   中英

Extension not found. Cogs discord.py

This is my code.

for filename in os.listdir('lib\commands'):
if filename.endswith('.py'):
    client.load_extension(f'cogs.{filename[:-3]}')

My error:

Exception has occurred: ExtensionNotFound
Extension 'cogs.ping_clear' could not be loaded.
  File "C:\Users\sakch\Desktop\Bot\main.py", line 15, in <module>
    client.load_extension(f'cogs.{filename[:-3]}')

This is my folder where the file is present.

You're putting the wrong path in load_extension . You should pass the same path as in os.listdir

for filename in os.listdir('lib\commands'):
    if filename.endswith('.py'):
        client.load_extension(f'lib.commands.{filename[:-3]}')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM