因此,我在使用Python中的Discord Bot時遇到了問題。不同源文件不一致的Python Bot
對於它的代碼變得太簡單了,所以我想把它分成不同的源文件。
(主文件)
...
import second_file
if message.content.lower().startswith("!Hi"):
second_file.hello()
(第二文件)
...
from __main__ import client
def hello():
await client.send_message(message.channel, "Hiii <3!")
我得到的錯誤是name "client" is not defined
。
我該怎麼辦? 謝謝:)
如果我的答案奏效,請將其標記爲正確,以便將來任何人都可以解決他們的問題。 – James
你應該看看創建Cog。使用Cogs將使您的生活變得如此簡單。編輯:你也需要看在commands.ext – xNinjaKittyx