未找到扩展。齿轮不和谐.py

时间:2021-01-28 08:50:57

标签: python discord.py discord.py-rewrite

这是我的代码。

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

我的错误:

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.

1 个答案:

答案 0 :(得分:0)

您在 load_extension 中放置了错误的路径。您应该传递与 os.listdir

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