且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么 on_message 会停止命令工作?

更新时间:2023-11-30 11:15:34

来自文档:

覆盖默认提供的 on_message 禁止运行任何额外的命令.要解决此问题,请在 on_message 的末尾添加 bot.process_commands(message) 行.例如:

Overriding the default provided on_message forbids any extra commands from running. To fix this, add a bot.process_commands(message) line at the end of your on_message. For example:

@bot.event
async def on_message(message):
    # do some extra stuff here

    await bot.process_commands(message)

默认的on_message包含对这个协程的调用,但是当你用你自己的on_message覆盖它时,你需要自己调用它.

The default on_message contains a call to this coroutine, but when you override it with your own on_message, you need to call it yourself.