I have made a discord bot in python which works fine. But now i wanted to implement a bad word filter. The bot will warn the person if he or she says a bad word. I also want it to be embedded. The error is on the last line (i.e. the await message.channel.send(embed=embedwarn). Where it says there’s a invalid syntax, but I can’t find it.
#bad words for the bot to detect
bad_words = ["Word1", "Word2"]
#send person a warning message
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if any(word in message.content.lower() for word in bad_words):
embedwarn=discord.Embed(title="Warning", description=f"Server: {member.name} \nReason: bad word")
await message.channel.send(embed=embedwarn)
>Solution :
This part of your code wasn’t properly indented.
if any(word in message.content.lower() for word in bad_words):
embedwarn=discord.Embed(title="Warning", description=f"Server: {member.name} \nReason: bad word")
await message.channel.send(embed=embedwarn)