D
D
dpushin12020-11-25 00:24:54
Python
dpushin1, 2020-11-25 00:24:54

How to find out the id of the person who added the reaction?

I have code:

@client.event
async def on_raw_reaction_add(ctx):
    with open('users.json', 'r') as f:
        captures = json.load(f)

    if not str(ctx.author.id) in captures:
        captures[str(ctx.author.id)] = {}
        captures[str(ctx.author.id)]['Captures'] = 0

calling it gives me an error,
'RawReactionActionEvent' object has no attribute 'author'

Yes, mb I don’t use the method at all, but I need that when adding a reaction, I need to recognize the ID of the person who added the reaction.

Sorry for the complex construction of sentences, and also for such a stupid question, I'm a teapot :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Nevzorov, 2020-11-25
@dpushin1

on_raw_reaction_addThe first argument to the event is not an object of type commands.Context, but an object of type RawReactionActionEvent:
https://discordpy.readthedocs.io/en/stable/api.htm...
https://discordpy.readthedocs.io/en/stable/api. htm...

@client.event
async def on_raw_reaction_add(raw_reaction):
    print(raw_reaction.user_id) # Выведет ID человека, поставившего реакцию
    print(raw_reaction.member.name) # Выведет имя человека, поставившего реакцию, в случае если реакция проставлена на сервере, в противном случае выпадет в ошибку "AttributeError: 'NoneType' object has no attribute 'name'"

K
kirillinyakin, 2020-11-25
@kirillinyakin

Try to write
print(ctx.__dict__)
There you will be given a dictionary with all the attributes, there it should be, the attribute responsible for the author

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question