简体   繁体   English

未找到扩展名。 齿轮 discord.py

[英]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 .您在load_extension中输入了错误的路径。 You should pass the same path as in os.listdir您应该传递与os.listdir相同的路径

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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