Answer the question
In order to leave comments, you need to log in
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
'RawReactionActionEvent' object has no attribute 'author'
Answer the question
In order to leave comments, you need to log in
on_raw_reaction_add
The 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'"
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 questionAsk a Question
731 491 924 answers to any question