aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Copilot <[email protected]>2025-11-06 20:39:50 +0000
committerGravatar GitHub <[email protected]>2025-11-06 20:39:50 +0000
commit163e72aabdf0c6f6845900caec51d2afda3f4508 (patch)
treee796a927b21f906326320758c102c7dff1bf4a33
parentProvide original context when DMing delete link for attachment paste upload (... (diff)
Handle closed DMs in paste uploader (#3434)
* Initial plan * Fix paste uploader to handle closed DMs Co-authored-by: jb3 <[email protected]> * Use discord.Forbidden instead of importing Forbidden Co-authored-by: jb3 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jb3 <[email protected]> Co-authored-by: Vivek Ashokkumar <[email protected]>
-rw-r--r--bot/exts/utils/attachment_pastebin_uploader.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/bot/exts/utils/attachment_pastebin_uploader.py b/bot/exts/utils/attachment_pastebin_uploader.py
index d39c03f10..b4db2ee07 100644
--- a/bot/exts/utils/attachment_pastebin_uploader.py
+++ b/bot/exts/utils/attachment_pastebin_uploader.py
@@ -128,10 +128,13 @@ class AutoTextAttachmentUploader(commands.Cog):
# Send the user a DM with the delete link for the paste.
# The angle brackets around the remove link are required to stop Discord from visiting the URL to produce a
# preview, thereby deleting the paste
- await message.author.send(
- f"[Click here](<{paste_response.removal}>) to delete the pasted attachment"
- f" contents copied from [your message](<{message.jump_url}>)"
- )
+ try:
+ await message.author.send(
+ f"[Click here](<{paste_response.removal}>) to delete the pasted attachment"
+ f" contents copied from [your message](<{message.jump_url}>)"
+ )
+ except discord.Forbidden:
+ log.debug(f"User {message.author} has DMs disabled, skipping delete link DM.")
# Edit the bot message to contain the link to the paste.
await bot_reply.edit(content=f"[Click here]({paste_response.link}) to see this code in our pastebin.")