0
votes

I have the following segment of code:

if message.author.name == "Rythm" or "Groovy":
        print("Deleting a message because it is from Rythm or Groovy")
        print(message.author.name)
        await message.delete()

I want to filter out nonsense bot messages that come from 2 other bots.

However this results in the bot deleting every users messages on the server.

Deleting a message because it is from Rythm or Groovy
StinkyDinky

The user "StinkyDinky" got his message deleted.

2

2 Answers

2
votes

Because you did if message.author.name == "Rythm" or "Groovy". This doesn't mean if the message author is Rythm or Groovy, that means if the message author is Rythm or Groovy exist. I know this is not a good explanation. but I assume you will understand. If you do:

if message.author.name == "Rythm" or message.author.name == "Great":

Your problem will be solved and if there is anything you do not understand, just comment.

0
votes

Your if statement always evaluates to true.

Try

if message.author.name in ( "Rythm", "Groovy") :