From 93332ad37bac7c17b444ea0ad5dcd3dc67fa6d30 Mon Sep 17 00:00:00 2001 From: Snazzah Date: Thu, 28 May 2026 13:57:04 -0400 Subject: [PATCH 1/5] fix: add stickers to forwards and fix partial stickers --- discord_http/message.py | 7 +++++++ discord_http/sticker.py | 30 +++++++++++++++--------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/discord_http/message.py b/discord_http/message.py index 3700e04..2663d1d 100644 --- a/discord_http/message.py +++ b/discord_http/message.py @@ -1510,6 +1510,7 @@ class MessageSnapshot: "content", "edited_timestamp", "embeds", + "stickers", "timestamp", "type", ) @@ -1540,6 +1541,12 @@ def __init__( self.attachments: list[Attachment] = [] """ The attachments of the message. """ + self.stickers: list[PartialSticker] = [ + PartialSticker(state=state, id=int(s["id"]), name=s["name"]) + for s in data.get("sticker_items", []) + ] + """ The stickers of the message. """ + self._from_data(data) def _from_data(self, data: dict) -> None: diff --git a/discord_http/sticker.py b/discord_http/sticker.py index ad40eed..da9ae11 100644 --- a/discord_http/sticker.py +++ b/discord_http/sticker.py @@ -23,6 +23,7 @@ class PartialSticker(PartialBase): "_state", "guild_id", "name", + "format_type" ) def __init__( @@ -31,7 +32,8 @@ def __init__( state: "DiscordAPI", id: int, # noqa: A002 name: str | None = None, - guild_id: int | None = None + guild_id: int | None = None, + format_type: int | None = 1 ): super().__init__(id=int(id)) self._state = state @@ -42,6 +44,9 @@ def __init__( self.guild_id: int | None = guild_id """ The ID of the guild this sticker is in, if any. """ + self.format_type: StickerFormatType = StickerFormatType(format_type) + """ The format type of the sticker. """ + def __repr__(self) -> str: return f"" @@ -187,7 +192,13 @@ async def delete( @property def url(self) -> str: """ Returns the sticker's URL. """ - return f"https://media.discordapp.net/stickers/{self.id}.png" + img_format = "png" + if self.format_type == StickerFormatType.gif: + img_format = "gif" + if self.format_type == StickerFormatType.lottie: + img_format = "json" + + return f"https://media.discordapp.net/stickers/{self.id}.{img_format}" class Sticker(PartialSticker): @@ -214,7 +225,8 @@ def __init__( state=state, id=int(data["id"]), name=data["name"], - guild_id=guild.id if guild else None + guild_id=guild.id if guild else None, + format_type=data["format_type"] ) self._raw_type: int = data["type"] @@ -225,9 +237,6 @@ def __init__( self.description: str = data["description"] """ The description of the sticker. """ - self.format_type: StickerFormatType = StickerFormatType(data["format_type"]) - """ The format type of the sticker. """ - self.pack_id: int | None = utils.get_int(data, "pack_id") """ The ID of the sticker pack this sticker belongs to, if any. """ @@ -251,15 +260,6 @@ def type(self) -> StickerType: """ The type of the sticker. """ return StickerType(self._raw_type) - @property - def url(self) -> str: - """ Returns the sticker's URL. """ - img_format = "png" - if self.format_type == StickerFormatType.gif: - img_format = "gif" - - return f"https://media.discordapp.net/stickers/{self.id}.{img_format}" - async def edit( self, *, From db7ece7d9d161ebe49bc6cf9eaecf313665ae223 Mon Sep 17 00:00:00 2001 From: Snazzah Date: Thu, 28 May 2026 14:03:36 -0400 Subject: [PATCH 2/5] fix contructors --- discord_http/message.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/discord_http/message.py b/discord_http/message.py index 2663d1d..dddcabf 100644 --- a/discord_http/message.py +++ b/discord_http/message.py @@ -1542,7 +1542,7 @@ def __init__( """ The attachments of the message. """ self.stickers: list[PartialSticker] = [ - PartialSticker(state=state, id=int(s["id"]), name=s["name"]) + PartialSticker(state=state, id=int(s["id"]), name=s["name"], format_type=s["format_type"]) for s in data.get("sticker_items", []) ] """ The stickers of the message. """ @@ -1650,7 +1650,7 @@ def __init__( """ The attachments of the message. """ self.stickers: list[PartialSticker] = [ - PartialSticker(state=state, id=int(s["id"]), name=s["name"]) + PartialSticker(state=state, id=int(s["id"]), name=s["name"], format_type=s["format_type"]) for s in data.get("sticker_items", []) ] """ The stickers of the message. """ From 85b201eec4d5a1cc4f3531a053818fef3491d485 Mon Sep 17 00:00:00 2001 From: Snazzah Date: Thu, 28 May 2026 14:07:30 -0400 Subject: [PATCH 3/5] chore: fix linting --- discord_http/sticker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/discord_http/sticker.py b/discord_http/sticker.py index da9ae11..000a105 100644 --- a/discord_http/sticker.py +++ b/discord_http/sticker.py @@ -21,9 +21,9 @@ class PartialSticker(PartialBase): __slots__ = ( "_state", + "format_type", "guild_id", - "name", - "format_type" + "name" ) def __init__( From 5807d29381b5d7f2e5d5741bdcf7e2429b19332f Mon Sep 17 00:00:00 2001 From: Snazzah Date: Thu, 28 May 2026 14:12:57 -0400 Subject: [PATCH 4/5] chore: move forwards sticker data down to the proper function --- discord_http/message.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/discord_http/message.py b/discord_http/message.py index dddcabf..c59ba52 100644 --- a/discord_http/message.py +++ b/discord_http/message.py @@ -1541,10 +1541,7 @@ def __init__( self.attachments: list[Attachment] = [] """ The attachments of the message. """ - self.stickers: list[PartialSticker] = [ - PartialSticker(state=state, id=int(s["id"]), name=s["name"], format_type=s["format_type"]) - for s in data.get("sticker_items", []) - ] + self.stickers: list[PartialSticker] = [] """ The stickers of the message. """ self._from_data(data) @@ -1577,6 +1574,12 @@ def _from_data(self, data: dict) -> None: for a in message["attachments"] ] + if message.get("sticker_items", None): + self.stickers = [ + PartialSticker(state=self._state, id=int(s["id"]), name=s["name"], format_type=s["format_type"]) + for s in message["sticker_items"] + ] + class Message(PartialMessage): """ Represents a message object. """ From ef6df984b273c856efb9e3841bb65ab9f6d869ea Mon Sep 17 00:00:00 2001 From: Snazzah Date: Thu, 28 May 2026 14:15:11 -0400 Subject: [PATCH 5/5] chore: fix retained slot --- discord_http/sticker.py | 1 - 1 file changed, 1 deletion(-) diff --git a/discord_http/sticker.py b/discord_http/sticker.py index 000a105..75bd210 100644 --- a/discord_http/sticker.py +++ b/discord_http/sticker.py @@ -208,7 +208,6 @@ class Sticker(PartialSticker): "_raw_type", "available", "description", - "format_type", "pack_id", "sort_value", "tags",