diff options
| author | 2025-11-02 00:31:33 +0000 | |
|---|---|---|
| committer | 2025-11-02 00:31:33 +0000 | |
| commit | dfe00e6a600d366baee2424c28bf1a7ef2e68535 (patch) | |
| tree | 16c18c243205f0fd85d398cb3a036674f1fe7551 | |
| parent | Initial plan (diff) | |
Fix paste uploader to handle closed DMs
Co-authored-by: jb3 <[email protected]>
| -rw-r--r-- | bot/exts/utils/attachment_pastebin_uploader.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bot/exts/utils/attachment_pastebin_uploader.py b/bot/exts/utils/attachment_pastebin_uploader.py index 1ea74b509..916d60096 100644 --- a/bot/exts/utils/attachment_pastebin_uploader.py +++ b/bot/exts/utils/attachment_pastebin_uploader.py @@ -3,6 +3,7 @@ from __future__ import annotations import re import discord +from discord import Forbidden from discord.ext import commands from pydis_core.utils import paste_service @@ -128,7 +129,10 @@ 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(content=f"[Click here](<{paste_response.removal}>) to delete your recent paste.") + try: + await message.author.send(content=f"[Click here](<{paste_response.removal}>) to delete your recent paste.") + except 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.") |