async def on_ready():语法错误:无效语法



我正在制作一个不和谐的机器人,我是python的新手,我已经查过了,但没有找到任何关于如何修复这个问题的答案,但我从这个代码中得到了错误

代码:

import discord
from discord.ext import commands
client = command.Bot(command_prefix="<")
@client.event
async def on_ready():
print("Bot is online")
@client.command()
synd def Test(ctx):
await ctx.send("Test successful")
client.run(Token)

错误行:

@client.event
async def on_ready():
print("Bot is online")

错误:

async def on_ready():
^
SyntaxError: invalid syntax

有人知道怎么解决这个问题吗?我使用的是Python版本:pip19.2.3(Python 3.8(

已编辑

打印功能需要另外4个空格:

async def on_ready():
print("Bot is online")

您可以尝试使用命令"python3文件名.py">

最新更新