Browse Source

Add defaults for message object parsing

pull/10125/head
dolfies 1 month ago
committed by GitHub
parent
commit
66f3548f3a
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 12
      discord/message.py

12
discord/message.py

@ -2194,15 +2194,15 @@ class Message(PartialMessage, Hashable):
self._state: ConnectionState = state
self.webhook_id: Optional[int] = utils._get_as_snowflake(data, 'webhook_id')
self.reactions: List[Reaction] = [Reaction(message=self, data=d) for d in data.get('reactions', [])]
self.attachments: List[Attachment] = [Attachment(data=a, state=self._state) for a in data['attachments']]
self.embeds: List[Embed] = [Embed.from_dict(a) for a in data['embeds']]
self.attachments: List[Attachment] = [Attachment(data=a, state=self._state) for a in data.get('attachments', [])]
self.embeds: List[Embed] = [Embed.from_dict(a) for a in data.get('embeds', [])]
self.activity: Optional[MessageActivityPayload] = data.get('activity')
self._edited_timestamp: Optional[datetime.datetime] = utils.parse_time(data['edited_timestamp'])
self._edited_timestamp: Optional[datetime.datetime] = utils.parse_time(data.get('edited_timestamp'))
self.type: MessageType = try_enum(MessageType, data['type'])
self.pinned: bool = data['pinned']
self.pinned: bool = data.get('pinned', False)
self.flags: MessageFlags = MessageFlags._from_value(data.get('flags', 0))
self.mention_everyone: bool = data['mention_everyone']
self.tts: bool = data['tts']
self.mention_everyone: bool = data.get('mention_everyone', False)
self.tts: bool = data.get('tts', False)
self.content: str = data['content']
self.nonce: Optional[Union[int, str]] = data.get('nonce')
self.position: Optional[int] = data.get('position')

Loading…
Cancel
Save