0

I can't understand why it says there two arguments when I gave one?

When I try to execute this code

@bot.event
async def on_reaction_add(reaction):
    fp = reaction.message.guild.name
    l = reaction.message
    if os.path.isfile(ph + fp + '-bug.txt'):
        f = open(ph + fp + '-bug.txt')
        u = open(ph + fp + '-mod.txt')
        lines1 = u.readlines()
        lines = f.readlines()
        if str(l.channel.id) == lines1[0]:
            if reaction.emoji == "✅":
                channel = bot.get_channel(int(lines[0]))
                await channel.send(l.content)
            elif reaction.emoji == "❌":
                await l.delete()

i get this error

Traceback (most recent call last):
  File "C:\Users\---\PycharmProjects\---\venv\lib\site-packages\discord\client.py", line 312, in _run_event
    await coro(*args, **kwargs)
TypeError: on_reaction_add() takes 1 positional argument but 2 were given```


Puk
  • 1
  • 2
  • Does this answer your question? [TypeError: method() takes 1 positional argument but 2 were given](https://stackoverflow.com/questions/23944657/typeerror-method-takes-1-positional-argument-but-2-were-given) – Oleg Kyrylchuk Apr 18 '20 at 10:37

1 Answers1

2

The on_reaction_add event requires the arguments reaction and user.
More you can read on this page!

So in order to make that event work, you should use it like this:

@bot.event
async def on_reaction_add(reaction, user):
    print(reaction) # Prints information about the reaction that was given.
    print(user) # Prints information about the user that gave the reaction.

Also: on_reaction_add() takes 1 positional argument but 2 were given
means that is expected to receive two arguments, but your event is only able to receive one

Kawaaii
  • 111
  • 6