當我使用它時,此代碼通常對我有用,但它停止作業。首先是其他異步定義,但現在 on_message 不起作用!
async def on_ready():
print("WizBot is currently online! Go check your Discord server; the bot should be active."
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith(' test'):
await message.channel.send('WizBot is up and running!')
WizBot 是我的機器人的名稱。此外,如果有幫助,我正在使用 repl.it。on_ready() 雖然有效,但我d在 def on_message(message) 中得到了一個 pyflakes SyntaxError 。
查看錯誤資訊
File "main.py", line 21
async def on_message(message):
^
SyntaxError: invalid syntax
有人可以幫忙嗎?
uj5u.com熱心網友回復:
我認為這是因為缺少右括號
print("WizBot is currently online! Go check your Discord server; the bot should be active."
uj5u.com熱心網友回復:
你錯過了行中的括號
print("WizBot is currently online! Go check your Discord server; the bot should be active."
它應該是:
print("WizBot is currently online! Go check your Discord server; the bot should be active.")
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/368970.html
