Skip to content

Commit

Permalink
Use httpx.head instead of httpx.stream for checking if stickers exist.
Browse files Browse the repository at this point in the history
I had previously completely forgotten about the existence of HEAD, and
so went with streaming the contents but never reading it.
  • Loading branch information
00-kat committed Feb 25, 2025
1 parent 305a437 commit ffbfbf3
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/utils/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ async def _get_sticker_embed(sticker: discord.Sticker) -> discord.Embed:
# Same as above but backward, just in case.
sticker.url.replace("media.discordapp.net", "cdn.discordapp.com"),
]:
async with client.stream("GET", u) as r:
if r.is_success:
embed = discord.Embed().set_image(url=u)
if sticker.format == discord.StickerFormatType.apng:
embed.set_footer(text="Unable to animate sticker.")
embed.color = discord.Color.orange()
return embed
if (await client.head(u)).is_success:
embed = discord.Embed().set_image(url=u)
if sticker.format == discord.StickerFormatType.apng:
embed.set_footer(text="Unable to animate sticker.")
embed.color = discord.Color.orange()
return embed

embed = discord.Embed()
embed.set_footer(text="Unable to attach sticker.")
Expand Down

0 comments on commit ffbfbf3

Please sign in to comment.