当我添加关键字事件时,Discord Bot停止处理命令

时间:2020-05-16 10:10:09

标签: python discord discord.py

我正在尝试向我的机器人添加一个功能,该功能会在检测到关键字时发送消息。 如, 关键字= [“ Hello There”] 用户:你好 \ Bot:您好!

client = commands.Bot(command_prefix=".")
.
.
.
@client.event
async def on_message(ctx):
    if ctx.author == client.user:
        return
    keywords = ["Hey","","Hi","Hello"]
    channel = ctx.channel
    for keyword in keywords:
        if keyword.lower() in ctx.content.lower():
            response = ("Hello sir!")
            await channel.send(response)

我正在为此使用此代码,但是每当我将此部分添加到我的代码中时,其他命令都无法处理,但是此事件和其他事件完全可以正常工作

1 个答案:

答案 0 :(得分:1)

您应该能够在await client.process_commands(ctx)的末尾使用on_message()将消息传递到@client.command()部分。