Browse Source

Add Message.position and Message.application_id attributes

pull/10109/head
Rapptz 3 years ago
committed by dolfies
parent
commit
5e1a80693f
  1. 18
      discord/message.py
  2. 1
      discord/types/message.py

18
discord/message.py

@ -1298,12 +1298,18 @@ class Message(PartialMessage, Hashable):
:attr:`MessageType.role_subscription_purchase` message.
.. versionadded:: 2.0
guild: Optional[:class:`Guild`]
The guild that the message belongs to, if applicable.
application_id: Optional[:class:`int`]
The application that sent this message, if applicable.
The application ID of the application that created this message if this
message was sent by an application-owned webhook or an interaction.
.. versionadded:: 2.0
position: Optional[:class:`int`]
A generally increasing integer with potentially gaps or duplicates that represents
the approximate position of the message in a thread.
.. versionadded:: 2.0
guild: Optional[:class:`Guild`]
The guild that the message belongs to, if applicable.
interaction: Optional[:class:`Interaction`]
The interaction that this message is a response to.
@ -1321,7 +1327,6 @@ class Message(PartialMessage, Hashable):
'tts',
'content',
'webhook_id',
'application_id',
'mention_everyone',
'embeds',
'mentions',
@ -1341,6 +1346,8 @@ class Message(PartialMessage, Hashable):
'call',
'interaction',
'role_subscription',
'application_id',
'position',
)
if TYPE_CHECKING:
@ -1363,7 +1370,6 @@ class Message(PartialMessage, Hashable):
self.id: int = int(data['id'])
self._state: ConnectionState = state
self.webhook_id: Optional[int] = utils._get_as_snowflake(data, 'webhook_id')
self.application_id: Optional[int] = utils._get_as_snowflake(data, 'application_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']]
@ -1376,6 +1382,8 @@ class Message(PartialMessage, Hashable):
self.tts: bool = data['tts']
self.content: str = data['content']
self.nonce: Optional[Union[int, str]] = data.get('nonce')
self.position: Optional[int] = data.get('position')
self.application_id: Optional[int] = utils._get_as_snowflake(data, 'application_id')
self.stickers: List[StickerItem] = [StickerItem(data=d, state=state) for d in data.get('sticker_items', [])]
self.call: Optional[CallMessage] = None

1
discord/types/message.py

@ -126,6 +126,7 @@ class Message(PartialMessage):
referenced_message: NotRequired[Optional[Message]]
interaction: NotRequired[MessageInteraction]
components: NotRequired[List[Component]]
position: NotRequired[int]
role_subscription_data: NotRequired[RoleSubscriptionData]

Loading…
Cancel
Save