簡體   English   中英

如何使用來自多個目錄的 cogs - Discord.py

[英]How to use cogs from multiple directories - Discord.py

是否可以使用來自不同文件夾的齒輪,例如commands/economy_commands/

我的代碼是

    for extension in os.listdir('commands/') and os.listdir('economy_commands/'):
        if extension.endswith('.py'):
            print('loaded ' + extension)
            client.load_extension(f'commands.{extension[:-3]}')
    print('----------')

我收到錯誤discord.ext.commands.errors.ExtensionNotFound: Extension 'commands.create_player_bank' could not be loaded.

create_player_bank位於economy_commands中。 任何幫助表示贊賞。

感謝 Benjin 的評論,這不是我的解決方案。 只是為了讓人們更容易看到

您需要使用 client.load_extension(f'economy_commands.{extension[:-3]}') 保存在該文件夾中的 cogs。 考慮將您的 for... 和... 拆分為兩個 for... 語句

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM