Python discord.py中的代码无法识别两个同时发生的事件

Python discord.py中的代码无法识别两个同时发生的事件,python,discord,Python,Discord,我正在为我朋友的不和制作一个机器人,它是一个计算器,它还必须用一些笑话来回答一些关键字,问题是,它通常像计算器一样工作,但当我添加用笑话回答关键字的事件时,计算器停止工作,只发送笑话。计算器如下所示: client = commands.Bot(command_prefix='&', help_command=None) @client.event async def on_ready(): print('on') def raizes(a: float, b: float

我正在为我朋友的不和制作一个机器人,它是一个计算器,它还必须用一些笑话来回答一些关键字,问题是,它通常像计算器一样工作,但当我添加用笑话回答关键字的事件时,计算器停止工作,只发送笑话。计算器如下所示:

client = commands.Bot(command_prefix='&', help_command=None)


@client.event
async def on_ready():
    print('on')

def raizes(a: float, b: float, c: float):
    return (-b + math.sqrt((b ** 2) - 4 * a * c)) / 2 * a, (-b - math.sqrt((b ** 2) - 4 * a * c)) / 2 * a


@client.command()
async def matraizes(ctx, a: float, b: float, c: float):
    res = raizes(a, b, c)
    await ctx.send(res)
然后,一旦我添加此事件,它就会停止工作:

@client.event  
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.lower().startswith('test'):
        await message.channel.send('ok')

在添加on message事件之前,discord.py已具有其默认的on message事件-用于处理命令。现在您创建了自己的事件,它覆盖了消息事件的默认值,但这很容易修复,因为您所要做的就是再次处理命令

@client.event
异步def on_消息(消息):
如果message.author==client.user:
返回
如果message.content.lower().startswith('test'):
等待消息.channel.send('ok')
等待客户端处理命令(消息)

如果使用
on_message
事件,您必须自己调用命令,因为您已经替换了解析和调用命令的默认逻辑。