python – Discord.py swear word filter


Im making a discord.py bot with rewrite. I want to make an anti-swear word filter so that if someone swears in a message it will delete the message and send a message. I have a swear word file with all the words that I need.

This is the code that i have so far, but it dosent work:

async def on_message(ctx, message):
    msg = message.content
    with open('badWords.txt') as BadWords:
        if msg in BadWords.read():
            await message.delete()
            await ctx.send("Dont use that word!")
        else:
            await ctx.process_commands(message)

If anyone could help that would be epic. Thanks!