Skip to content

Commit 163e72a

Browse files
Copilotjb3vivekashok1221
authored
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]>
1 parent a5b76e8 commit 163e72a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

bot/exts/utils/attachment_pastebin_uploader.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,13 @@ async def on_message(self, message: discord.Message) -> None:
128128
# Send the user a DM with the delete link for the paste.
129129
# The angle brackets around the remove link are required to stop Discord from visiting the URL to produce a
130130
# preview, thereby deleting the paste
131-
await message.author.send(
132-
f"[Click here](<{paste_response.removal}>) to delete the pasted attachment"
133-
f" contents copied from [your message](<{message.jump_url}>)"
134-
)
131+
try:
132+
await message.author.send(
133+
f"[Click here](<{paste_response.removal}>) to delete the pasted attachment"
134+
f" contents copied from [your message](<{message.jump_url}>)"
135+
)
136+
except discord.Forbidden:
137+
log.debug(f"User {message.author} has DMs disabled, skipping delete link DM.")
135138

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

0 commit comments

Comments
 (0)