@@ -356,15 +356,16 @@ async def delete_bad_message_with_thread(
356356 grace period specified in `delay` in seconds, it will delete `message`, if possible, and send the message contents via DM to the affected user.
357357 """
358358 deletion_successful = False
359+ is_thread_message = isinstance (message .channel , discord .Thread )
359360 try :
360361 await asyncio .sleep (delay ) # allow cancelling during delay
361362 except asyncio .CancelledError :
362363 return
363364
364365 else :
365366 try :
366- if isinstance ( message . channel , discord . Thread ) :
367- await message .channel .delete ()
367+ if is_thread_message :
368+ await message .channel .delete () # type: ignore
368369 await message .delete ()
369370 except discord .NotFound :
370371 # don't error here if thread and/or message were already deleted
@@ -373,12 +374,23 @@ async def delete_bad_message_with_thread(
373374 deletion_successful = True
374375
375376 if deletion_successful :
377+ target_channel_url = (
378+ (
379+ message .channel .parent .jump_url # type: ignore
380+ if message .channel .parent # type: ignore
381+ else f"https://discord.com/channels/{ message .guild } /{ message .channel .parent_id } " # type: ignore
382+ )
383+ if is_thread_message
384+ else message .channel .jump_url
385+ )
386+
376387 await message .author .send (
377- content = "Your showcase message/post was deleted for not meeting the message formatting rules."
388+ content = f"### Pygame Community"
389+ f"Your showcase message/post in { target_channel_url } was deleted for not meeting the message formatting rules."
378390 "\n Here is the message content and attachments in case you need to retrieve them:\n "
379391 + (
380- f"**Post title:** `{ message .channel .name } `"
381- if isinstance ( message . channel , discord . Thread )
392+ f"**Post title:** `{ message .channel .name } `" # type: ignore
393+ if is_thread_message
382394 else ""
383395 ),
384396 files = [
@@ -388,8 +400,8 @@ async def delete_bad_message_with_thread(
388400 ),
389401 * [
390402 await att .to_file (use_cached = True )
391- for att in message .attachments
392- if att .size < 2 ** 20 * 25
403+ for i , att in enumerate ( message .attachments )
404+ if att .size < 2 ** 20 * 25 and i < 9
393405 ],
394406 ],
395407 )
0 commit comments