Skip to content

Commit

Permalink
Ignore Discord undocumented field
Browse files Browse the repository at this point in the history
  • Loading branch information
4Kaylum committed Feb 6, 2024
1 parent 1880b91 commit f1433cb
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions novus/models/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from dataclasses import dataclass
from datetime import datetime as dt
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

from typing_extensions import Self

Expand Down Expand Up @@ -61,6 +61,15 @@ class EmbedMedia:
height: int | None = None
width: int | None = None

@classmethod
def _from_data(cls, data: dict[Any, Any]) -> Self:
return cls(
url=data["url"],
proxy_url=data.get("proxy_url"),
width=data.get("width"),
height=data.get("height"),
)

def _to_data(self) -> MediaPayload:
return {
"url": self.url
Expand Down Expand Up @@ -263,9 +272,9 @@ def _from_data(cls, data: EmbedPayload) -> Self:
if "footer" in data:
embed._footer = EmbedFooter(**data["footer"])
if "image" in data:
embed._image = EmbedMedia(**data["image"])
embed._image = EmbedMedia._from_data(data["image"])
if "thumbnail" in data:
embed._thumbnail = EmbedMedia(**data["thumbnail"])
embed._thumbnail = EmbedMedia._from_data(data["thumbnail"])
if "video" in data:
embed._video = EmbedVideo(**data["video"])
if "provider" in data:
Expand Down

0 comments on commit f1433cb

Please sign in to comment.