Skip to content

Conversation

Copy link

Copilot AI commented Nov 2, 2025

Fix paste uploader to handle when DMs are closed

  • Analyze the code at line 131 in attachment_pastebin_uploader.py
  • Add import for discord.Forbidden exception
  • Wrap the author.send() call in try/except block
  • Continue with returning the link in the original channel when DM fails
  • Review the change to ensure it follows the existing pattern in the codebase
  • Verify linting passes
  • Address review feedback: Use discord.Forbidden instead of importing Forbidden

The fix catches the discord.Forbidden exception when a user has DMs disabled and logs the event at debug level, then continues with the paste upload flow by posting the link in the original channel.

Original prompt

This section details on the original issue you should resolve

<issue_title>Paste uploader does not catch when dms are closed</issue_title>
<issue_description>We're not catching or responding when a user cannot be DMed when uploading a paste message: we should try/catch the author.send() method.

I don't know what behaviour we should have regarding deleting the paste, continuing with the upload, or what we should do if DMs are closed.

await message.author.send(content=f"[Click here](<{paste_response.removal}>) to delete your recent paste.")

related to #3422</issue_description>

<agent_instructions>Add a try/except (for the correct exception type) and continue with returning the link in the original channel</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@jb3 The user has already reacted to say they want it uploaded, having the deletion link is a nicety but isn't required, DevOps can still delete pastes or they expire after a period, it's not the end of the world.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: jb3 <20439493+jb3@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix paste uploader not responding when DMs are closed Handle closed DMs in paste uploader Nov 2, 2025
Copilot AI requested a review from jb3 November 2, 2025 00:34
Copilot finished work on behalf of jb3 November 2, 2025 00:34
import re

import discord
from discord import Forbidden
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of specifically importing Forbidden, use discord.Forbidden here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to use discord.Forbidden in commit 76d1d7b.

@jb3
Copy link
Member

jb3 commented Nov 2, 2025

@copilot Please address review feedback.

Co-authored-by: jb3 <20439493+jb3@users.noreply.github.com>
Copy link
Author

Copilot AI commented Nov 2, 2025

@copilot Please address review feedback.

Review feedback addressed in commit 76d1d7b.

Copilot AI requested a review from jb3 November 2, 2025 00:41
Copilot finished work on behalf of jb3 November 2, 2025 00:41
@jb3 jb3 marked this pull request as ready for review November 2, 2025 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Paste uploader does not catch when dms are closed

2 participants