简体   繁体   中英

Cant do Multiple on_message events in discord.py

I want make a Discord bot that auto supports user... I tried to do auto response!

I tried this both things!

Both gave me a Error and dindnt work please help me.

@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')

Welcome to SO! Firstly, next time you post a question, please post the details of the error that you're encountering.

Secondly, the second implementation is more correct than the first. It just has a syntax error.

This should be correct:

@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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM