Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Invalid syntax in discord bot python

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading