Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support GIF stickers #1464

Merged
merged 5 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/1464.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support GIF sticker image format
2 changes: 1 addition & 1 deletion hikari/api/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3945,7 +3945,7 @@ async def create_sticker(
The tag for the sticker.
image : hikari.files.Resourceish
The 320x320 image for the sticker. Maximum upload size is 500kb.
This can be a still or an animated PNG or a Lottie.
This can be a still PNG, an animated PNG, a Lottie, or a GIF.

.. note::
Lottie support is only available for verified and partnered
Expand Down
2 changes: 1 addition & 1 deletion hikari/guilds.py
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,7 @@ async def create_sticker(
The tag for the sticker.
image : hikari.files.Resourceish
The 320x320 image for the sticker. Maximum upload size is 500kb.
This can be a still or an animated PNG or a Lottie.
This can be a still PNG, an animated PNG, a Lottie, or a GIF.

Other Parameters
----------------
Expand Down
2 changes: 1 addition & 1 deletion hikari/internal/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def compile_to_file(
# undocumented on the Discord docs.
CDN_CHANNEL_ICON: typing.Final[CDNRoute] = CDNRoute("/channel-icons/{channel_id}/{hash}", {PNG, *JPEG_JPG, WEBP})

CDN_STICKER: typing.Final[CDNRoute] = CDNRoute("/stickers/{sticker_id}", {PNG, LOTTIE}, is_sizable=False)
CDN_STICKER: typing.Final[CDNRoute] = CDNRoute("/stickers/{sticker_id}", {PNG, LOTTIE, GIF}, is_sizable=False)
CDN_STICKER_PACK_BANNER: typing.Final[CDNRoute] = CDNRoute(
"/app-assets/710982414301790216/store/{hash}", {PNG, *JPEG_JPG, WEBP}
)
Expand Down
3 changes: 3 additions & 0 deletions hikari/stickers.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class StickerFormatType(int, enums.Enum):
More information can be found here: <https://airbnb.io/lottie/>
"""

GIF = 4
"""A GIF sticker."""


@attr.define(hash=True, kw_only=True, weakref_slot=False)
class StickerPack(snowflakes.Unique):
Expand Down
23 changes: 21 additions & 2 deletions tests/hikari/impl/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3973,9 +3973,28 @@ async def test_fetch_guild_sticker(self, rest_client):
rest_client._request.assert_awaited_once_with(expected_route)
rest_client._entity_factory.deserialize_guild_sticker.assert_called_once_with({"id": "123"})

@pytest.mark.skip("TODO")
async def test_create_sticker(self, rest_client):
...
rest_client.create_sticker = mock.AsyncMock()
file = object()

sticker = await rest_client.create_sticker(
90210,
"NewSticker",
"funny",
file,
description="A sticker",
reason="blah blah blah",
)
assert sticker is rest_client.create_sticker.return_value

rest_client.create_sticker.assert_awaited_once_with(
90210,
"NewSticker",
"funny",
file,
description="A sticker",
reason="blah blah blah",
)

async def test_edit_sticker(self, rest_client):
expected_route = routes.PATCH_GUILD_STICKER.compile(guild=123, sticker=456)
Expand Down
15 changes: 10 additions & 5 deletions tests/hikari/test_guilds.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,19 +742,24 @@ async def test_create_sticker(self, model):
model.app.rest.create_sticker = mock.AsyncMock()
file = object()

sticker = await model.create_sticker("NewSticker", "funny", file)
sticker = await model.create_sticker(
"NewSticker",
"funny",
file,
description="A sticker",
reason="blah blah blah",
)
assert sticker is model.app.rest.create_sticker.return_value

model.app.rest.create_sticker.assert_awaited_once_with(
90210,
"NewSticker",
"funny",
file,
description=undefined.UNDEFINED,
reason=undefined.UNDEFINED,
description="A sticker",
reason="blah blah blah",
)

assert sticker is model.app.rest.create_sticker.return_value

@pytest.mark.asyncio()
async def test_edit_sticker(self, model):
model.app.rest.edit_sticker = mock.AsyncMock()
Expand Down