2021年4月25日星期日

Im making a discord bot that says hi when someone says hello but it also says hi when someone uses it in a word like "tHIng. How do i prevent that?

So whenever someone says hi in a word (eg: thing) it replies with hi. How do I make it so that it only replies with hi if its by itself? (Also I'm 14 and a beginner so please don't make it overly complicated). just so you know it runs fine and whenever someone says hello it replies but I don't want it to say hello when the word hi is in a word or sentence

Here is my code:

@client.event  async def on_message(message):      greetings = ["hello" , "hi" , "hey" , "wassup" , "sup" , "yo"]        if any(word in message.content.lower()for word in greetings):          if message.author == client.user:              return                  await message.channel.send("Hello there, " + str(message.author))      print("Reply to hello command has been executed")  
https://stackoverflow.com/questions/67248816/im-making-a-discord-bot-that-says-hi-when-someone-says-hello-but-it-also-says-hi April 25, 2021 at 08:58AM

没有评论:

发表评论