@@ -356,15 +356,16 @@ async def delete_bad_message_with_thread(
356
356
grace period specified in `delay` in seconds, it will delete `message`, if possible, and send the message contents via DM to the affected user.
357
357
"""
358
358
deletion_successful = False
359
+ is_thread_message = isinstance (message .channel , discord .Thread )
359
360
try :
360
361
await asyncio .sleep (delay ) # allow cancelling during delay
361
362
except asyncio .CancelledError :
362
363
return
363
364
364
365
else :
365
366
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
368
369
await message .delete ()
369
370
except discord .NotFound :
370
371
# don't error here if thread and/or message were already deleted
@@ -373,12 +374,23 @@ async def delete_bad_message_with_thread(
373
374
deletion_successful = True
374
375
375
376
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
+
376
387
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."
378
390
"\n Here is the message content and attachments in case you need to retrieve them:\n "
379
391
+ (
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
382
394
else ""
383
395
),
384
396
files = [
@@ -388,8 +400,8 @@ async def delete_bad_message_with_thread(
388
400
),
389
401
* [
390
402
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
393
405
],
394
406
],
395
407
)
0 commit comments