Skip to content
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
5 changes: 4 additions & 1 deletion interactions/models/discord/asset.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from typing import TYPE_CHECKING, Optional, Union

import attrs
Expand Down Expand Up @@ -74,7 +75,9 @@ def as_url(self, *, extension: str | None = None, size: int = 4096) -> str:
@property
def animated(self) -> bool:
"""True if this asset is animated."""
return bool(self.hash) and self.hash.startswith("a_")
# damn hashes with version numbers
_hash = re.sub(r"^v\d+_", "", self.hash or "")
return bool(self.hash) and _hash.startswith("a_")

async def fetch(self, extension: Optional[str] = None, size: Optional[int] = None) -> bytes:
"""
Expand Down
8 changes: 8 additions & 0 deletions interactions/models/discord/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class User(BaseUser):
)

banner: Optional["Asset"] = attrs.field(repr=False, default=None, metadata=docs("The user's banner"))
avatar_decoration: Optional["Asset"] = attrs.field(
repr=False, default=None, metadata=docs("The user's avatar decoration")
)
accent_color: Optional["Color"] = attrs.field(
default=None,
converter=optional_c(Color),
Expand All @@ -156,6 +159,11 @@ def _process_dict(cls, data: Dict[str, Any], client: "Client") -> Dict[str, Any]
if data.get("premium_type", None) is None:
data["premium_type"] = 0

if data.get("avatar_decoration", None):
data["avatar_decoration"] = Asset.from_path_hash(
client, "avatar-decoration-presets/{}", data["avatar_decoration"]
)

return data

@property
Expand Down