@client.event
async def on_raw_reaction_add(payload):
channel = client.get_channel(payload.channel_id)
message = await channel.fetch_message(payload.message_id)
guild = client.get_guild(payload.guild_id)
reaction = discord.utils.get(message.reactions, emoji=payload.emoji.name)
# only work if it is the client
if payload.member.id == client.user.id:
return
if payload.message_id == 898092846287028225 and reaction.emoji == '✅':
role = discord.utils.get(guild.roles, name='LASTTASK')
await payload.member.add_roles(role)
@client.event
async def on_raw_reaction_remove(payload):
if payload.message_id in roles_assignment_setup['massage_id']:
if payload.emoji.name in roles_assignment_setup["emoji_to_role"]:
guild = client.get_guild(payload.guild_id)
member_remove_role = await guild.fetch_member(payload.user_id)
role = discord.utils.get(guild.roles,
id=roles_assignment_setup["emoji_to_role"][payload.emoji.name])
await member_remove_role.remove_roles(role)
log.info(f"Role was removed {member_remove_role} - {role}")