Skip to content

Commit 35cfb54

Browse files
committed
Use "charset" in Attachment.content_type to determine that it's text-based.
Previously, `on_message` used `Attachment.content_type.startswith("text")` for this, but this is false for some text-based files (like json).
1 parent ceffc88 commit 35cfb54

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

bot/exts/utils/attachment_pastebin_uploader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async def on_message_delete(self, message: discord.Message) -> None:
7979
async def on_message(self, message: discord.Message) -> None:
8080
"""Listens for messages containing attachments and offers to upload them to the pastebin."""
8181
# Check if the message contains an embedded file and is not sent by a bot.
82-
if message.author.bot or not any(a.content_type.startswith("text") for a in message.attachments):
82+
if message.author.bot or not any("charset" in a.content_type for a in message.attachments):
8383
return
8484

8585
log.trace(f"Offering to upload attachments for {message.author} in {message.channel}, message {message.id}")

0 commit comments

Comments
 (0)