diff options
| author | 2019-12-03 20:23:13 -0800 | |
|---|---|---|
| committer | 2019-12-03 20:23:41 -0800 | |
| commit | 336c6d523031b611ebc4823583c7d8b4ed1964c2 (patch) | |
| tree | f5b005f537023cb8f1d5f5366d38393d35837f92 | |
| parent | Utils: support returning URLs from send_attachments (diff) | |
Utils: use the guild's filesize_limit to determine max attachment size
| -rw-r--r-- | bot/utils/messages.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/bot/utils/messages.py b/bot/utils/messages.py index 40c20c7ec..fa1ee80b5 100644 --- a/bot/utils/messages.py +++ b/bot/utils/messages.py @@ -9,8 +9,6 @@ from discord.errors import HTTPException from bot.constants import Emojis -MAX_SIZE = 1024 * 1024 * 8 # 8 Mebibytes - async def wait_for_deletion( message: Message, @@ -62,9 +60,10 @@ async def send_attachments(message: Message, destination: Union[TextChannel, Web urls = [] for attachment in message.attachments: try: - # This should avoid most files that are too large, but some may get through hence the try-catch. # Allow 512 bytes of leeway for the rest of the request. - if attachment.size <= MAX_SIZE - 512: + # This should avoid most files that are too large, + # but some may get through hence the try-catch. + if attachment.size <= destination.guild.filesize_limit - 512: with BytesIO() as file: await attachment.save(file) attachment_file = File(file, filename=attachment.filename) |