I need my bot to reply when someone says Hi or Hello, but when someone says a word including the letters ‘hi’ it will also respond to it, any way to fix this and tell the code to look for the exact word only? I’m using a very simple code ofcourse:
if message.content.startswith('hi') or message.content.startswith('hello'):
#await message.reply("Hello Bro 🌹")
>Solution :
split by spaces and check the first index. you’ll still have an issue with the bot responding to some who’s saying hi or hello to someone else, but it won’t trigger on other words.
if message.content.split(" ")[0] in ['hi', 'Hi', 'hello', 'Hello']:
# respond
if you want more general check allowing for any capitalization (hI, hElLo, …)
if message.content.split(" ")[0].lower() in ['hi', 'hello']:
# respond