mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
Add Thread.created_at
This commit is contained in:
parent
a1dbc0ca27
commit
7f54c45886
@ -25,6 +25,7 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Callable, Dict, Iterable, List, Optional, Union, TYPE_CHECKING
|
from typing import Callable, Dict, Iterable, List, Optional, Union, TYPE_CHECKING
|
||||||
|
from datetime import datetime
|
||||||
import time
|
import time
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
@ -143,6 +144,7 @@ class Thread(Messageable, Hashable):
|
|||||||
'archiver_id',
|
'archiver_id',
|
||||||
'auto_archive_duration',
|
'auto_archive_duration',
|
||||||
'archive_timestamp',
|
'archive_timestamp',
|
||||||
|
'_created_at',
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, *, guild: Guild, state: ConnectionState, data: ThreadPayload):
|
def __init__(self, *, guild: Guild, state: ConnectionState, data: ThreadPayload):
|
||||||
@ -189,6 +191,7 @@ class Thread(Messageable, Hashable):
|
|||||||
self.archive_timestamp = parse_time(data['archive_timestamp'])
|
self.archive_timestamp = parse_time(data['archive_timestamp'])
|
||||||
self.locked = data.get('locked', False)
|
self.locked = data.get('locked', False)
|
||||||
self.invitable = data.get('invitable', True)
|
self.invitable = data.get('invitable', True)
|
||||||
|
self._created_at = parse_time(data.get('create_timestamp'))
|
||||||
|
|
||||||
def _update(self, data):
|
def _update(self, data):
|
||||||
try:
|
try:
|
||||||
@ -273,7 +276,7 @@ class Thread(Messageable, Hashable):
|
|||||||
if parent is None:
|
if parent is None:
|
||||||
raise ClientException('Parent channel not found')
|
raise ClientException('Parent channel not found')
|
||||||
return parent.category
|
return parent.category
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def category_id(self) -> Optional[int]:
|
def category_id(self) -> Optional[int]:
|
||||||
"""The category channel ID the parent channel belongs to, if applicable.
|
"""The category channel ID the parent channel belongs to, if applicable.
|
||||||
@ -294,6 +297,16 @@ class Thread(Messageable, Hashable):
|
|||||||
raise ClientException('Parent channel not found')
|
raise ClientException('Parent channel not found')
|
||||||
return parent.category_id
|
return parent.category_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def created_at(self) -> Optional[datetime]:
|
||||||
|
"""An aware timestamp of when the thread was created in UTC.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
This timestamp only exists for threads created after 9 January 2022, otherwise returns ``None``.
|
||||||
|
"""
|
||||||
|
return self._created_at
|
||||||
|
|
||||||
def is_private(self) -> bool:
|
def is_private(self) -> bool:
|
||||||
""":class:`bool`: Whether the thread is a private thread.
|
""":class:`bool`: Whether the thread is a private thread.
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ class _ThreadMetadataOptional(TypedDict, total=False):
|
|||||||
archiver_id: Snowflake
|
archiver_id: Snowflake
|
||||||
locked: bool
|
locked: bool
|
||||||
invitable: bool
|
invitable: bool
|
||||||
|
create_timestamp: str
|
||||||
|
|
||||||
|
|
||||||
class ThreadMetadata(_ThreadMetadataOptional):
|
class ThreadMetadata(_ThreadMetadataOptional):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user