Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bot/exts/utils/attachment_pastebin_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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
Contributor 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.

from discord.ext import commands
from pydis_core.utils import paste_service

Expand Down Expand Up @@ -128,7 +129,10 @@ async def on_message(self, message: discord.Message) -> None:
# 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.")
Expand Down