@@ -935,7 +935,7 @@ async def on_typing(self, channel, user, _):
935
935
return
936
936
await thread .recipient .trigger_typing ()
937
937
938
- async def on_raw_reaction_add (self , payload ):
938
+ async def handle_reaction_events (self , payload , * , add ):
939
939
user = self .get_user (payload .user_id )
940
940
if user .bot :
941
941
return
@@ -960,9 +960,9 @@ async def on_raw_reaction_add(self, payload):
960
960
thread = await self .threads .find (recipient = user )
961
961
if not thread :
962
962
return
963
-
964
963
if (
965
- message .embeds
964
+ add
965
+ and message .embeds
966
966
and str (reaction ) == str (close_emoji )
967
967
and self .config .get ("recipient_thread_close" )
968
968
):
@@ -992,8 +992,21 @@ async def on_raw_reaction_add(self, payload):
992
992
logger .warning ("Failed to find linked message for reactions: %s" , e )
993
993
return
994
994
995
- if await self .add_reaction (linked_message , reaction ):
996
- await self .add_reaction (message , reaction )
995
+ if add :
996
+ if await self .add_reaction (linked_message , reaction ):
997
+ await self .add_reaction (message , reaction )
998
+ else :
999
+ try :
1000
+ await linked_message .remove_reaction (reaction , self .user )
1001
+ await message .remove_reaction (reaction , self .user )
1002
+ except (discord .HTTPException , discord .InvalidArgument ) as e :
1003
+ logger .warning ("Failed to remove reaction: %s" , e )
1004
+
1005
+ async def on_raw_reaction_add (self , payload ):
1006
+ await self .handle_reaction_events (payload , add = True )
1007
+
1008
+ async def on_raw_reaction_remove (self , payload ):
1009
+ await self .handle_reaction_events (payload , add = False )
997
1010
998
1011
async def on_guild_channel_delete (self , channel ):
999
1012
if channel .guild != self .modmail_guild :
0 commit comments