Skip to content

Commit faa9534

Browse files
fix: gif stickers use a different base url (Pycord-Development#2781)
* Update sticker.py Signed-off-by: UK <[email protected]> * style(pre-commit): auto fixes from pre-commit.com hooks * Update CHANGELOG.md * changelog again --------- Signed-off-by: UK <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ca62594 commit faa9534

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,16 @@ These changes are available on the `master` branch, but have not yet been releas
9999
([#2564](https://github.com/Pycord-Development/pycord/pull/2564))
100100
- Fixed `Subscription.renewal_sku_ids` not accepting `None` from the received payload.
101101
([#2709](https://github.com/Pycord-Development/pycord/pull/2709))
102-
- Fixed `ForumChannel.edit` allowing `default_reaction_emoji` to be `None`
102+
- Fixed `ForumChannel.edit` allowing `default_reaction_emoji` to be `None`.
103103
([#2739](https://github.com/Pycord-Development/pycord/pull/2739))
104104
- Fixed missing `None` type hints in `Select.__init__`.
105-
([#2746])(https://github.com/Pycord-Development/pycord/pull/2746)
105+
([#2746](https://github.com/Pycord-Development/pycord/pull/2746))
106106
- Updated `valid_locales` to support `in` and `es-419`.
107-
([#2767])(https://github.com/Pycord-Development/pycord/pull/2767)
107+
([#2767](https://github.com/Pycord-Development/pycord/pull/2767))
108108
- Fixed `Webhook.edit` not working with `attachments=[]`.
109-
([#2779])(https://github.com/Pycord-Development/pycord/pull/2779)
109+
([#2779](https://github.com/Pycord-Development/pycord/pull/2779))
110+
- Fixed GIF-based `Sticker` returning the wrong `url`.
111+
([#2781](https://github.com/Pycord-Development/pycord/pull/2781))
110112

111113
### Changed
112114

discord/sticker.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,12 @@ def __init__(self, *, state: ConnectionState, data: StickerItemPayload):
212212
self.format: StickerFormatType = try_enum(
213213
StickerFormatType, data["format_type"]
214214
)
215-
self.url: str = f"{Asset.BASE}/stickers/{self.id}.{self.format.file_extension}"
215+
base = (
216+
"https://media.discordapp.net"
217+
if self.format is StickerFormatType.gif
218+
else Asset.BASE
219+
)
220+
self.url: str = f"{base}/stickers/{self.id}.{self.format.file_extension}"
216221

217222
def __repr__(self) -> str:
218223
return f"<StickerItem id={self.id} name={self.name!r} format={self.format}>"
@@ -288,7 +293,12 @@ def _from_data(self, data: StickerPayload) -> None:
288293
self.format: StickerFormatType = try_enum(
289294
StickerFormatType, data["format_type"]
290295
)
291-
self.url: str = f"{Asset.BASE}/stickers/{self.id}.{self.format.file_extension}"
296+
base = (
297+
"https://media.discordapp.net"
298+
if self.format is StickerFormatType.gif
299+
else Asset.BASE
300+
)
301+
self.url: str = f"{base}/stickers/{self.id}.{self.format.file_extension}"
292302

293303
def __repr__(self) -> str:
294304
return f"<Sticker id={self.id} name={self.name!r}>"

0 commit comments

Comments
 (0)