Update to support new pin endpoints

This commit is contained in:
Soheab
2025-08-14 02:47:14 +02:00
committed by GitHub
parent 50caa3c82c
commit 705eb2c2a5
4 changed files with 179 additions and 17 deletions

View File

@ -2185,6 +2185,7 @@ class Message(PartialMessage, Hashable):
'call',
'purchase_notification',
'message_snapshots',
'_pinned_at',
)
if TYPE_CHECKING:
@ -2224,6 +2225,8 @@ class Message(PartialMessage, Hashable):
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.message_snapshots: List[MessageSnapshot] = MessageSnapshot._from_value(state, data.get('message_snapshots'))
# Set by Messageable.pins
self._pinned_at: Optional[datetime.datetime] = None
self.poll: Optional[Poll] = None
try:
@ -2644,6 +2647,18 @@ class Message(PartialMessage, Hashable):
# Fall back to guild threads in case one was created after the message
return self._thread or self.guild.get_thread(self.id)
@property
def pinned_at(self) -> Optional[datetime.datetime]:
"""Optional[:class:`datetime.datetime`]: An aware UTC datetime object containing the time
when the message was pinned.
.. note::
This is only set for messages that are returned by :meth:`abc.Messageable.pins`.
.. versionadded:: 2.6
"""
return self._pinned_at
@property
@deprecated('interaction_metadata')
def interaction(self) -> Optional[MessageInteraction]: