prevent images from being too big for discord
This commit is contained in:
@@ -135,6 +135,9 @@ async def on_message(message: discord.Message):
|
|||||||
else:
|
else:
|
||||||
with tempfile.NamedTemporaryFile(delete=False) as output:
|
with tempfile.NamedTemporaryFile(delete=False) as output:
|
||||||
img.save(output, format="JPEG")
|
img.save(output, format="JPEG")
|
||||||
|
if os.stat(output.name).st_size > 8 * 1024 * 1024: # 8MB
|
||||||
|
await message.channel.send(":warning:\nOutput image is too big to be sent by discord")
|
||||||
|
else:
|
||||||
response = None
|
response = None
|
||||||
meme_id = utils.sanitize_input(args[0])
|
meme_id = utils.sanitize_input(args[0])
|
||||||
if len(args) == 1 and meme_id not in ["image", "text"]:
|
if len(args) == 1 and meme_id not in ["image", "text"]:
|
||||||
|
|||||||
Reference in New Issue
Block a user