我做了一个自动响应特定消息的命令。该命令有效,但是它使我所有其他命令不起作用(discord.py重写)

时间:2020-06-04 05:01:38

标签: python discord.py-rewrite

这是我打招呼时用于命令响应的代码。这将起作用,但是如果我在所有命令都不起作用后尝试使用命令,并且从代码中删除了该命令,它将再次起作用。使用命令时没有错误代码。我真的对如何解决此问题迷失了,谁能知道为什么会这样,如果可以的话,我该如何解决?

@client.event
async def on_message(message):
    channel = client.get_channel(CHANNEL)
    hello = "hello"
    if message.content.count(hello) > 0:
        message = "Whats up!"
        await channel.send(message)

1 个答案:

答案 0 :(得分:0)

使用on_message事件时,您需要process_commands()才能使命令起作用:

@client.event
async def on_message(message):
    await client.process_commands(message)

    # checking against lower case string will be more consistent with finding more "hello"s
    if message.content.lower().count("hello") > 0:
        await message.channel.send("What's up!")

参考: