Skip to content

Commit

Permalink
fix: use media.discordapp.net for gif stickers (#1189)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftinv committed May 17, 2024
1 parent 086fc53 commit 02fc355
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/1189.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix base URL for stickers with :attr:`StickerFormatType.gif`.
3 changes: 3 additions & 0 deletions disnake/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ class Asset(AssetMixin):

BASE = "https://cdn.discordapp.com"

# only used in special cases where Discord doesn't provide an asset on the CDN url
BASE_MEDIA = "https://media.discordapp.net"

def __init__(self, state: AnyState, *, url: str, key: str, animated: bool = False) -> None:
self._state: AnyState = state
self._url: str = url
Expand Down
4 changes: 3 additions & 1 deletion disnake/sticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ class _StickerTag(Hashable, AssetMixin):
@property
def url(self) -> str:
""":class:`str`: The url for the sticker's image."""
return f"{Asset.BASE}/stickers/{self.id}.{self.format.file_extension}"
# https://github.com/discord/discord-api-docs/issues/6675#issuecomment-1954755672
base = Asset.BASE_MEDIA if self.format is StickerFormatType.gif else Asset.BASE
return f"{base}/stickers/{self.id}.{self.format.file_extension}"

async def read(self) -> bytes:
"""|coro|
Expand Down

0 comments on commit 02fc355

Please sign in to comment.