diff --git a/discordrpc/types.py b/discordrpc/types.py index da79d11..b867447 100644 --- a/discordrpc/types.py +++ b/discordrpc/types.py @@ -33,13 +33,18 @@ def __init__(self, data:dict=None): self.avatar: str = self._parse_avatar(data) self.bot: bool = data.get('bot', False) self.premium_type: int = int(data.get('premium_type', 0)) + self.avatar_decoration: str = self._parse_decoration((data.get("avatar_decoration_data") or {})) def _parse_avatar(self, data:dict, size:int=1024) -> str: if data.get('avatar'): ext = "gif" if data.get('avatar').startswith("a_") else "png" return f"https://cdn.discordapp.com/avatars/{self.id}/{data.get('avatar')}.{ext}?size={size}" - else: - return f"https://cdn.discordapp.com/embed/avatars/0.png" + return f"https://cdn.discordapp.com/embed/avatars/0.png" + + def _parse_decoration(self, data:dict, size:int=1024) -> str: + if data.get("asset"): + return f"https://cdn.discordapp.com/avatar-decoration-presets/{data.get('asset')}.png?size={size}" + return "" def __str__(self): return f"User({self.name})" @@ -51,14 +56,20 @@ def __init__(self, data:dict=None): self.name: str = data.get("name") self.description: str = data.get("description") self.icon: str = self._parse_icon(data.get("icon")) + self.cover: str = self._parse_cover(data.get("cover_image")) self.verified: bool = data.get("is_verified", False) self.public: bool = data.get("bot_public", False) - def _parse_icon(self, icon_id:str, size:int=512) -> str: + def _parse_icon(self, icon_id:str, size:int=1024) -> str: if icon_id: return f"https://cdn.discordapp.com/app-icons/{self.id}/{icon_id}.png?size={size}" return "https://cdn.discordapp.com/embed/avatars/1.png" + def _parse_cover(self, icon_id:str, size:int=1024) -> str: + if icon_id: + return f"https://cdn.discordapp.com/app-icons/{self.id}/{icon_id}.png?size={size}&keep_aspect_ratio=true" + return "" + def __str__(self): return f"Application({self.name})"