From 1f50e946a67dd32fab53b293612e70453e57c93b Mon Sep 17 00:00:00 2001 From: Steele Farnsworth Date: Wed, 29 Jan 2025 19:38:59 -0500 Subject: Exit early if none of the attachments are text. Previously, the bot might have offered to upload the attachments in a message containing only images, and then done nothing. --- bot/exts/utils/attachment_pastebin_uploader.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bot/exts/utils/attachment_pastebin_uploader.py b/bot/exts/utils/attachment_pastebin_uploader.py index cc507f39e..d6d3c7d2c 100644 --- a/bot/exts/utils/attachment_pastebin_uploader.py +++ b/bot/exts/utils/attachment_pastebin_uploader.py @@ -43,7 +43,7 @@ class EmbedFileHandler(commands.Cog): async def on_message(self, message: discord.Message) -> None: """Listens for messages containing attachments and offers to upload them to the pastebin.""" # Check if the message contains an embedded file and is not sent by a bot - if message.author.bot or not message.attachments: + if message.author.bot or not any(a.content_type.startswith("text") for a in message.attachments): return bot_reply = await message.reply(f"React with {PASTEBIN_UPLOAD_EMOJI} to upload your file to our paste bin") @@ -76,7 +76,6 @@ class EmbedFileHandler(commands.Cog): async with aiohttp.ClientSession() as session: paste_response = await paste_service.send_to_paste_service(files=files, http_session=session) except (paste_service.PasteTooLongError, ValueError): - # paste is too long await bot_reply.edit(content="Your paste is too long, and couldn't be uploaded.") return except paste_service.PasteUploadError: -- cgit v1.2.3