[英]Why is on_message() not working? discord.py
這段代碼在我使用它時通常對我有用,但它停止了工作。 首先使用其他異步定義,但現在 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() 雖然有效,但我在 def on_message(message) 中得到了d
的 pyflakes SyntaxError。 查看錯誤信息
File "main.py", line 21
async def on_message(message):
^
SyntaxError: invalid syntax
有人可以幫忙嗎?
我認為這是因為缺少右括號
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."
它應該是:
print("WizBot is currently online! Go check your Discord server; the bot should be active.")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.