Skip to content

Commit

Permalink
increase spoiler file limit to reflect discord changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lmaotrigine committed Jan 6, 2024
1 parent 19be5c0 commit 7507bf2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cogs/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ async def redirect_post(self, ctx: Context, title: str, text: str | None) -> tup

files = []
total_bytes = 0
eight_mb = 8 * 1024 * 1024
max_mb = 25 * 1024 * 1024
for attach in ctx.message.attachments:
async with ctx.session.get(attach.url) as resp:
if resp.status != 200:
Expand All @@ -1045,14 +1045,14 @@ async def redirect_post(self, ctx: Context, title: str, text: str | None) -> tup
content_length = int(resp.headers.get('Content-Length', ''))

# file too big, skip it
if (total_bytes + content_length) > eight_mb:
if (total_bytes + content_length) > max_mb:
continue

total_bytes += content_length
fp = io.BytesIO(await resp.read())
files.append(discord.File(fp, filename=attach.filename))

if total_bytes >= eight_mb:
if total_bytes >= max_mb:
break

# on mobile, messages that are deleted immediately sometimes persist client side
Expand Down Expand Up @@ -1146,7 +1146,7 @@ async def spoiler(self, ctx: Context, title: str, *, text: str | None = None):
The only media types supported are png, gif, jpeg, mp4,
and webm.
Only 8MiB of total media can be uploaded at once.
Only 25MiB of total media can be uploaded at once.
Sorry, Discord limitation.
To opt-in to a post's spoiler you must press the button.
Expand Down

0 comments on commit 7507bf2

Please sign in to comment.