Skip to content

Commit dfe00e6

Browse files
Copilotjb3
andcommitted
Fix paste uploader to handle closed DMs
Co-authored-by: jb3 <20439493+jb3@users.noreply.github.com>
1 parent 0cbb0aa commit dfe00e6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

bot/exts/utils/attachment_pastebin_uploader.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import re
44

55
import discord
6+
from discord import Forbidden
67
from discord.ext import commands
78
from pydis_core.utils import paste_service
89

@@ -128,7 +129,10 @@ async def on_message(self, message: discord.Message) -> None:
128129
# Send the user a DM with the delete link for the paste.
129130
# The angle brackets around the remove link are required to stop Discord from visiting the URL to produce a
130131
# preview, thereby deleting the paste
131-
await message.author.send(content=f"[Click here](<{paste_response.removal}>) to delete your recent paste.")
132+
try:
133+
await message.author.send(content=f"[Click here](<{paste_response.removal}>) to delete your recent paste.")
134+
except Forbidden:
135+
log.debug(f"User {message.author} has DMs disabled, skipping delete link DM.")
132136

133137
# Edit the bot message to contain the link to the paste.
134138
await bot_reply.edit(content=f"[Click here]({paste_response.link}) to see this code in our pastebin.")

0 commit comments

Comments
 (0)