diff --git a/jarvis/cogs/image.py b/jarvis/cogs/image.py index d15fdd8..bcd57db 100644 --- a/jarvis/cogs/image.py +++ b/jarvis/cogs/image.py @@ -94,9 +94,20 @@ class ImageCog(Scale): filename = url.split("/")[-1] data = None - async with self._session.get(url) as resp: - if resp.status == 200: - data = await resp.read() + try: + async with self._session.get(url) as resp: + resp.raise_for_status() + if resp.content_type in ["image/jpeg", "image/png"]: + data = await resp.read() + else: + await ctx.send( + "Unsupported content type. Please send a URL to a JPEG or PNG", + ephemeral=True, + ) + return + except Exception: + await ctx.send("Failed to retrieve image. Please verify url", ephemeral=True) + return size = len(data) if size <= tgt_size: