Skip to content

Commit 02fc355

Browse files
committed
fix: use media.discordapp.net for gif stickers (#1189)
1 parent 086fc53 commit 02fc355

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

changelog/1189.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix base URL for stickers with :attr:`StickerFormatType.gif`.

disnake/asset.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ class Asset(AssetMixin):
195195

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

198+
# only used in special cases where Discord doesn't provide an asset on the CDN url
199+
BASE_MEDIA = "https://media.discordapp.net"
200+
198201
def __init__(self, state: AnyState, *, url: str, key: str, animated: bool = False) -> None:
199202
self._state: AnyState = state
200203
self._url: str = url

disnake/sticker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ class _StickerTag(Hashable, AssetMixin):
128128
@property
129129
def url(self) -> str:
130130
""":class:`str`: The url for the sticker's image."""
131-
return f"{Asset.BASE}/stickers/{self.id}.{self.format.file_extension}"
131+
# https://github.com/discord/discord-api-docs/issues/6675#issuecomment-1954755672
132+
base = Asset.BASE_MEDIA if self.format is StickerFormatType.gif else Asset.BASE
133+
return f"{base}/stickers/{self.id}.{self.format.file_extension}"
132134

133135
async def read(self) -> bytes:
134136
"""|coro|

0 commit comments

Comments
 (0)