File tree Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -1415,11 +1415,12 @@ async def on_message_delete(self, message):
1415
1415
if not thread :
1416
1416
return
1417
1417
try :
1418
- message = await thread .find_linked_message_from_dm (message )
1418
+ message = await thread .find_linked_message_from_dm (message , get_thread_channel = True )
1419
1419
except ValueError as e :
1420
1420
if str (e ) != "Thread channel message not found." :
1421
1421
logger .debug ("Failed to find linked message to delete: %s" , e )
1422
1422
return
1423
+ message = message [0 ]
1423
1424
embed = message .embeds [0 ]
1424
1425
embed .set_footer (text = f"{ embed .footer .text } (deleted)" , icon_url = embed .footer .icon_url )
1425
1426
await message .edit (embed = embed )
Original file line number Diff line number Diff line change @@ -695,7 +695,7 @@ async def delete_message(
695
695
await asyncio .gather (* tasks )
696
696
697
697
async def find_linked_message_from_dm (
698
- self , message , either_direction = False
698
+ self , message , either_direction = False , get_thread_channel = False
699
699
) -> typing .List [discord .Message ]:
700
700
701
701
joint_id = None
@@ -726,6 +726,10 @@ async def find_linked_message_from_dm(
726
726
else :
727
727
raise ValueError ("Thread channel message not found." )
728
728
729
+ if get_thread_channel :
730
+ # end early as we only want the main message from thread channel
731
+ return linked_messages
732
+
729
733
if joint_id is None :
730
734
joint_id = get_joint_id (linked_messages [0 ])
731
735
if joint_id is None :
Original file line number Diff line number Diff line change @@ -467,7 +467,9 @@ def get_joint_id(message: discord.Message) -> typing.Optional[int]:
467
467
"""
468
468
if message .embeds :
469
469
try :
470
- return int (getattr (message .embeds [0 ].author , "url" , "" ).split ("#" )[- 1 ])
470
+ url = getattr (message .embeds [0 ].author , "url" , "" )
471
+ if url :
472
+ return int (url .split ("#" )[- 1 ])
471
473
except ValueError :
472
474
pass
473
475
return None
You can’t perform that action at this time.
0 commit comments