mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-05 17:36:15 +00:00
Add support for get sticker pack
This commit is contained in:
@ -28,8 +28,7 @@ import unicodedata
|
||||
|
||||
from .mixins import Hashable
|
||||
from .asset import Asset, AssetMixin
|
||||
from .utils import cached_slot_property, find, snowflake_time, get, MISSING, _get_as_snowflake
|
||||
from .errors import InvalidData
|
||||
from .utils import cached_slot_property, snowflake_time, get, MISSING, _get_as_snowflake
|
||||
from .enums import StickerType, StickerFormatType, try_enum
|
||||
|
||||
__all__ = (
|
||||
@ -51,7 +50,6 @@ if TYPE_CHECKING:
|
||||
Sticker as StickerPayload,
|
||||
StandardSticker as StandardStickerPayload,
|
||||
GuildSticker as GuildStickerPayload,
|
||||
ListPremiumStickerPacks as ListPremiumStickerPacksPayload,
|
||||
)
|
||||
|
||||
|
||||
@ -353,9 +351,12 @@ class StandardSticker(Sticker):
|
||||
|
||||
Retrieves the sticker pack that this sticker belongs to.
|
||||
|
||||
.. versionchanged:: 2.5
|
||||
Now raises ``NotFound`` instead of ``InvalidData``.
|
||||
|
||||
Raises
|
||||
--------
|
||||
InvalidData
|
||||
NotFound
|
||||
The corresponding sticker pack was not found.
|
||||
HTTPException
|
||||
Retrieving the sticker pack failed.
|
||||
@ -365,13 +366,8 @@ class StandardSticker(Sticker):
|
||||
:class:`StickerPack`
|
||||
The retrieved sticker pack.
|
||||
"""
|
||||
data: ListPremiumStickerPacksPayload = await self._state.http.list_premium_sticker_packs()
|
||||
packs = data['sticker_packs']
|
||||
pack = find(lambda d: int(d['id']) == self.pack_id, packs)
|
||||
|
||||
if pack:
|
||||
return StickerPack(state=self._state, data=pack)
|
||||
raise InvalidData(f'Could not find corresponding sticker pack for {self!r}')
|
||||
data = await self._state.http.get_sticker_pack(self.pack_id)
|
||||
return StickerPack(state=self._state, data=data)
|
||||
|
||||
|
||||
class GuildSticker(Sticker):
|
||||
|
Reference in New Issue
Block a user