So.. I want to know how could I do the classic events work with my json variables.
Let me explain, I created a json file which memorates the, channelid, reactions, assigned role, and total reactions, of a message. For example if I run the command :
.r <messageID> <emoji> <role> add
The JSON File writes this :
{
<messageID> :{
'channelID' : <channelID of the message>
'reaction(1)' : '<emoji>' //unicode name value | I used "unicode.name(emoji)"
'assigned role(1)' : '<role>'
'total rrs' : 1
}
}
I ve made everything, but the events, I can t figure them out, I tried with payload, that on_reaction_raw_add/remove
functions, but it does not work, or supposely I don t know how to use them..
I also tried with the other ones, on_reaction_add/remove()
but I can't figure them out, it does not work, could omeone help me, in case you need more details about the code, you can comment below and I ll edit the message or reply yours.
Thank you,
RVZWN.
CodePudding user response:
I assume the events in general, there is an event called 'on_reaction_add' which lets you do something whenever you add a reaction ( 'on_reaction_remove' for when you remove one ) Inside this method, you can get the reaction from the user who placed it.
in the reaction value you can get the actual message by doing reaction.message ( Discord.Message ) and reaction.emoji ( which gives you the actual emoji )
async def on_reaction_add(self, reaction: discord.Reaction, user:
discord.Member):
# Rest of code here about reactions, dumping to json and things
If I didn't answer it correctly then specify what you're asking, If you need anything else I'll be more than happy to help.