How to make Discord.py detect uppercase and lowercase word format?

OK, so I am working on a say command in Discord.py. I want it to detect if the user use bad word that in my banned.txt list, it won't say it. The problem is, how to make it detect uppercase and lowercase letter? For example, in my list, it has "nigga", but the user use "NiGGa". How to make the BOT detect it and won't let the bot say that? This is my code so far:

    @commands.command()
    async def say(self, message, *, content):
      fp  = open('banned.txt')
      bad_list = [word.strip() for line in fp.readlines() for word in line.split(',') if word.strip() if word.lower()]
      if any(word in content for word in bad_list):
          await message.reply("Don't you dare!")
      else:
          await message.channel.trigger_typing()
          await message.reply(f"```{content}```")    

I can't upload the banned.txt here, as it violate the ToS.



Read more here: https://stackoverflow.com/questions/68478666/how-to-make-discord-py-detect-uppercase-and-lowercase-word-format

Content Attribution

This content was originally published by JimmyBlue at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: