Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用“多个”;关于“U消息”;哪些是有效的?_Python_Discord.py - Fatal编程技术网

Python 如何使用“多个”;关于“U消息”;哪些是有效的?

Python 如何使用“多个”;关于“U消息”;哪些是有效的?,python,discord.py,Python,Discord.py,我有这两条on_消息,不管我将创建多少,只创建最后一条on_消息就行了,在这种情况下,我的测试只起作用,我看到了等待客户端。process_命令(消息)修复了其他命令起作用的问题,但我不能创建多条on_消息,所以请帮助为什么需要多条on_消息?只需将这些方法中的所有代码组合在一起,并将其放在一个方法中 例如: @client.event async def on_message(message): if message.content.startswith("hey"

我有这两条on_消息,不管我将创建多少,只创建最后一条on_消息就行了,在这种情况下,我的测试只起作用,我看到了等待客户端。process_命令(消息)修复了其他命令起作用的问题,但我不能创建多条on_消息,所以请帮助为什么需要多条on_消息?只需将这些方法中的所有代码组合在一起,并将其放在一个方法中

例如:

@client.event
async def on_message(message):
    if message.content.startswith("hey"):
        await message.reply('こんにちは', mention_author=True)

    await client.process_commands(message)

@client.event
async def on_message(message):
    if message.content.startswith("test"):
        await message.reply('123', mention_author=True)

    await client.process_commands(message)

为什么您需要该方法的倍数?只需将这些方法中的所有代码组合在一起,并将其放在一个方法中

例如:

@client.event
async def on_message(message):
    if message.content.startswith("hey"):
        await message.reply('こんにちは', mention_author=True)

    await client.process_commands(message)

@client.event
async def on_message(message):
    if message.content.startswith("test"):
        await message.reply('123', mention_author=True)

    await client.process_commands(message)

谢谢我没那么聪明谢谢我没那么聪明