Fix filesize checker

This commit is contained in:
Nexus 2023-11-04 17:01:21 +00:00
parent c7b326899b
commit 4ca6b7f1d9
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -914,7 +914,7 @@ class OtherCog(commands.Cog):
MAX_SIZE_MB = ctx.guild.filesize_limit / 1024 / 1024 MAX_SIZE_MB = ctx.guild.filesize_limit / 1024 / 1024
if MAX_SIZE_MB == 8.0: if MAX_SIZE_MB == 8.0:
MAX_SIZE_MB = 25.0 MAX_SIZE_MB = 25.0
REAL_MAX_SIZE_MB = MAX_SIZE_MB
if disable_filesize_buffer is False: if disable_filesize_buffer is False:
MAX_SIZE_MB *= 0.9 MAX_SIZE_MB *= 0.9
BYTES_REMAINING = (MAX_SIZE_MB - 0.256) * 1024 * 1024 BYTES_REMAINING = (MAX_SIZE_MB - 0.256) * 1024 * 1024
@ -1129,7 +1129,7 @@ class OtherCog(commands.Cog):
embed.description += f"\N{warning sign}\ufe0f {file.name} is empty.\n" embed.description += f"\N{warning sign}\ufe0f {file.name} is empty.\n"
continue continue
st = file.stat().st_size st = file.stat().st_size
if st / 1024 / 1024 >= MAX_SIZE_MB or st >= BYTES_REMAINING: if st / 1024 / 1024 >= REAL_MAX_SIZE_MB:
units = ["B", "KB", "MB", "GB", "TB"] units = ["B", "KB", "MB", "GB", "TB"]
st_r = st st_r = st
while st_r > 1024: while st_r > 1024:
@ -1140,7 +1140,7 @@ class OtherCog(commands.Cog):
file.name, file.name,
round(st_r, 2), round(st_r, 2),
units[0], units[0],
MAX_SIZE_MB, REAL_MAX_SIZE_MB,
) )
continue continue
else: else: