无法在discord.py中执行多个on_message事件

时间:2020-09-29 19:06:06

标签: python discord.py discord.py-rewrite

我想让Discord机器人自动支持用户... 我试图做自动回复!

我都尝试了这两种方法!

两个人都给了我一个错误和努力的工作 请帮助我。

@bot.event
async def on_message(message):
    if string.lower('Need') in message.content:
        if string.lower('Help') in message.content:
            await ctx.send("Test")

@bot.event
async def on_message(message):
    if string.lower('Hey') in message.content:
        if string.lower('i') in message.content:
            await ctx.send("Hola")


----------------------------And i Tryed this------------------------------------

@bot.event
async def on_message(message):
    if string.lower('Hey') in message.content:
        if string.lower('i') in message.content:
            print('Keyword found in message')
        else:
    if string.lower('Test') in message.content:
        if string.lower('hi') in message.content:
            print('Keyword found in message')

1 个答案:

答案 0 :(得分:0)

欢迎您!首先,下次您发布问题时,请发布您遇到的错误的详细信息。

第二,第二种实现比第一种更正确。只是有语法错误。

这应该是正确的:

@bot.event
async def on_message(message):
    if string.lower('Hey') in message.content:
        if string.lower('i') in message.content:
            print('Keyword found in message')
    
    if string.lower('Test') in message.content:
        if string.lower('hi') in message.content:
            print('Keyword found in message')