0

When the reaction is added, it doesn't get deleted, and there is no error anywhere.

@client.event
    async def on_reaction_add(reaction, user):
        if reaction.message.author == 'sample#0000':
            await reaction.message.clear_reactions()

It works without the author check. I am new to discord bots, so whats wrong with this?

The Amateur Coder
  • 789
  • 3
  • 11
  • 33

1 Answers1

0

reaction.message.author is of the discord.Member type. So, it'll never be equal to a username (with the discriminator/number tag).

You can use its string representation for the check:

...

if str(reaction.message.author) == "sample#0000":
    await reaction.message.clear_reactions()

...

But as users might change their usernames, you should check their ids instead:

...

if reaction.message.author.id == <integer id>:
    await reaction.message.clear_reactions()

...

If you want to check the username for some reason, see my previous answer for a comparison of commonly used properties of users (applicable to Members) that are username strings (display names, full usernames, etc.).

From these two answers:

I've not tested the codes, but they should work fine. Also, I'm not sure if it's a big deal, but the @client.event should probably be indented.

The Amateur Coder
  • 789
  • 3
  • 11
  • 33