From c8954906cb0870538c08a3056429bab5f5028032 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 23 Nov 2020 06:05:25 -0500 Subject: [PATCH] Sticker implementation cleanup --- discord/enums.py | 2 +- discord/sticker.py | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/discord/enums.py b/discord/enums.py index 03ca4f976..871d7e499 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -52,7 +52,7 @@ __all__ = ( 'WebhookType', 'ExpireBehaviour', 'ExpireBehavior', - 'StickerType' + 'StickerType', ) def _create_value_cls(name): diff --git a/discord/sticker.py b/discord/sticker.py index e67314e10..a88d2af17 100644 --- a/discord/sticker.py +++ b/discord/sticker.py @@ -64,10 +64,10 @@ class Sticker(Hashable): The sticker's image tags: List[:class:`str`] A list of tags for the sticker - preview_asset: Optional[:class:`str`] + preview_image: Optional[:class:`str`] The sticker's preview asset hash """ - __slots__ = ('_state', 'id', 'name', 'description', 'pack_id', 'format', 'image', 'tags', 'preview_asset') + __slots__ = ('_state', 'id', 'name', 'description', 'pack_id', 'format', 'image', 'tags', 'preview_image') def __init__(self, *, state, data): self._state = state @@ -77,8 +77,13 @@ class Sticker(Hashable): self.pack_id = int(data['pack_id']) self.format = try_enum(StickerType, data['format_type']) self.image = data['asset'] - self.tags = [tag.strip() for tag in data.get('tags', '').split(',')] - self.preview_asset = data.get('preview_asset') + + try: + self.tags = [tag.strip() for tag in data['tags'].split(',')] + except KeyError: + self.tags = [] + + self.preview_image = data.get('preview_image') def __repr__(self): return '<{0.__class__.__name__} id={0.id} name={0.name!r}>'.format(self) @@ -122,7 +127,7 @@ class Sticker(Hashable): ------ InvalidArgument Invalid ``size``. - + Returns ------- Optional[:class:`Asset`]