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. :attr:`MessageType.role_subscription_purchase` message.
.. versionadded:: 2.0 .. versionadded:: 2.0
guild: Optional[:class:`Guild`]
The guild that the message belongs to, if applicable.
application_id: Optional[:class:`int`] 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 .. 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`] interaction: Optional[:class:`Interaction`]
The interaction that this message is a response to. The interaction that this message is a response to.
@ -1321,7 +1327,6 @@ class Message(PartialMessage, Hashable):
'tts', 'tts',
'content', 'content',
'webhook_id', 'webhook_id',
'application_id',
'mention_everyone', 'mention_everyone',
'embeds', 'embeds',
'mentions', 'mentions',
@ -1341,6 +1346,8 @@ class Message(PartialMessage, Hashable):
'call', 'call',
'interaction', 'interaction',
'role_subscription', 'role_subscription',
'application_id',
'position',
) )
if TYPE_CHECKING: if TYPE_CHECKING:
@ -1363,7 +1370,6 @@ class Message(PartialMessage, Hashable):
self.id: int = int(data['id']) self.id: int = int(data['id'])
self._state: ConnectionState = state self._state: ConnectionState = state
self.webhook_id: Optional[int] = utils._get_as_snowflake(data, 'webhook_id') 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.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.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.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.tts: bool = data['tts']
self.content: str = data['content'] self.content: str = data['content']
self.nonce: Optional[Union[int, str]] = data.get('nonce') 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.stickers: List[StickerItem] = [StickerItem(data=d, state=state) for d in data.get('sticker_items', [])]
self.call: Optional[CallMessage] = None self.call: Optional[CallMessage] = None

1
discord/types/message.py

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

Loading…
Cancel
Save