CeilingSystems
CeilingSystems

Reputation: 185

Discord bot deleting wrong messages?

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.

Upvotes: 0

Views: 149

Answers (2)

AKX
AKX

Reputation: 169388

Your if statement always evaluates to true.

Try

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

Upvotes: 0

Nurqm
Nurqm

Reputation: 4743

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.

Upvotes: 2

Related Questions