Skip to content

Commit bf5f590

Browse files
committed
Add serialise to base components, and remove fields on media items that are receive only
1 parent d7a2967 commit bf5f590

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

discord/components.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ def _raw_construct(cls, **kwargs) -> Self:
163163
def to_dict(self) -> ComponentBasePayload:
164164
raise NotImplementedError
165165

166+
async def serialise(self, ctx) -> ComponentBasePayload:
167+
return self.to_dict()
168+
166169

167170
class ActionRow(Component):
168171
"""Represents a Discord Bot UI Kit Action Row.
@@ -963,13 +966,13 @@ def _from_data(cls, data: UnfurledMediaItemPayload, state: Optional[ConnectionSt
963966
return self
964967

965968
def _update(self, data: UnfurledMediaItemPayload, state: Optional[ConnectionState]) -> None:
966-
self.proxy_url = data['proxy_url']
969+
self.proxy_url = data.get('proxy_url')
967970
self.height = data.get('height')
968971
self.width = data.get('width')
969972
self.content_type = data.get('content_type')
970973
self._flags = data.get('flags', 0)
971974
self.placeholder = data.get('placeholder')
972-
self.loading_state = try_enum(MediaItemLoadingState, data['loading_state'])
975+
self.loading_state = try_enum(MediaItemLoadingState, data.get('loading_state'))
973976
self._state = state
974977

975978
def __repr__(self) -> str:

0 commit comments

Comments
 (0)