aboutsummaryrefslogtreecommitdiff
path: root/discord/sticker.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-04-16 11:21:13 -0400
committerRapptz <[email protected]>2021-04-16 11:27:23 -0400
commit9eaf1e85e4e987b5f874a7ba4c3ed13de10fd154 (patch)
tree83a60b0aaff3c1b63868631418cb7583adda054d /discord/sticker.py
parentAdd `fetch_message` for webhooks (diff)
downloaddiscord.py-9eaf1e85e4e987b5f874a7ba4c3ed13de10fd154.tar.xz
discord.py-9eaf1e85e4e987b5f874a7ba4c3ed13de10fd154.zip
Rewrite Asset design
This is a breaking change. This does the following transformations, assuming `asset` represents an asset type. Object.is_asset_animated() => Object.asset.is_animated() Object.asset => Object.asset.key Object.asset_url => Object.asset_url Object.asset_url_as => Object.asset.replace(...) Since the asset type now requires a key (or hash, if you will), Emoji had to be flattened similar to how Attachment was done since these assets are keyed solely ID. Emoji.url (Asset) => Emoji.url (str) Emoji.url_as => removed Emoji.url.read => Emoji.read Emoji.url.save => Emoji.save This transformation was also done to PartialEmoji.
Diffstat (limited to 'discord/sticker.py')
-rw-r--r--discord/sticker.py35
1 files changed, 4 insertions, 31 deletions
diff --git a/discord/sticker.py b/discord/sticker.py
index 0b3c66d9..8a1e4518 100644
--- a/discord/sticker.py
+++ b/discord/sticker.py
@@ -62,12 +62,10 @@ class Sticker(Hashable):
The id of the sticker's pack.
format: :class:`StickerType`
The format for the sticker's image.
- image: :class:`str`
- The sticker's image.
tags: List[:class:`str`]
A list of tags for the sticker.
"""
- __slots__ = ('_state', 'id', 'name', 'description', 'pack_id', 'format', 'image', 'tags')
+ __slots__ = ('_state', 'id', 'name', 'description', 'pack_id', 'format', '_image', 'tags')
def __init__(self, *, state, data):
self._state = state
@@ -76,7 +74,7 @@ class Sticker(Hashable):
self.description = data['description']
self.pack_id = int(data['pack_id'])
self.format = try_enum(StickerType, data['format_type'])
- self.image = data['asset']
+ self._image = data['asset']
try:
self.tags = [tag.strip() for tag in data['tags'].split(',')]
@@ -95,7 +93,7 @@ class Sticker(Hashable):
return snowflake_time(self.id)
@property
- def image_url(self):
+ def image(self):
"""Returns an :class:`Asset` for the sticker's image.
.. note::
@@ -106,32 +104,7 @@ class Sticker(Hashable):
Optional[:class:`Asset`]
The resulting CDN asset.
"""
- return self.image_url_as()
-
- def image_url_as(self, *, size=1024):
- """Optionally returns an :class:`Asset` for the sticker's image.
-
- The size must be a power of 2 between 16 and 4096.
-
- .. note::
- This will return ``None`` if the format is ``StickerType.lottie``.
-
- Parameters
- -----------
- size: :class:`int`
- The size of the image to display.
-
- Raises
- ------
- InvalidArgument
- Invalid ``size``.
-
- Returns
- -------
- Optional[:class:`Asset`]
- The resulting CDN asset or ``None``.
- """
if self.format is StickerType.lottie:
return None
- return Asset._from_sticker_url(self._state, self, size=size)
+ return Asset._from_sticker_url(self._state, self.id, self._image)