Compare commits
1 Commits
JDJGInc/2.
...
JDJGInc/pa
Author | SHA1 | Date | |
---|---|---|---|
9e4c0f1065 |
@ -94,3 +94,18 @@ class Object(Hashable):
|
|||||||
def created_at(self) -> datetime.datetime:
|
def created_at(self) -> datetime.datetime:
|
||||||
""":class:`datetime.datetime`: Returns the snowflake's creation time in UTC."""
|
""":class:`datetime.datetime`: Returns the snowflake's creation time in UTC."""
|
||||||
return utils.snowflake_time(self.id)
|
return utils.snowflake_time(self.id)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def worker_id(self) -> int:
|
||||||
|
""":class:`int`: Returns the worker id that made the snowflake."""
|
||||||
|
return (self.id & 0x3E0000) >> 17
|
||||||
|
|
||||||
|
@property
|
||||||
|
def process_id(self) -> int:
|
||||||
|
""":class:`int`: Returns the process id that made the snowflake."""
|
||||||
|
return (self.id & 0x1F000) >> 12
|
||||||
|
|
||||||
|
@property
|
||||||
|
def increment_id(self) -> int:
|
||||||
|
""":class:`int`: Returns the increment id that made the snowflake."""
|
||||||
|
return (self.id & 0xFFF)
|
||||||
|
@ -84,7 +84,6 @@ __all__ = (
|
|||||||
"escape_mentions",
|
"escape_mentions",
|
||||||
"as_chunks",
|
"as_chunks",
|
||||||
"format_dt",
|
"format_dt",
|
||||||
"generate_snowflake",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
DISCORD_EPOCH = 1420070400000
|
DISCORD_EPOCH = 1420070400000
|
||||||
@ -1021,23 +1020,3 @@ def format_dt(dt: datetime.datetime, /, style: Optional[TimestampStyle] = None)
|
|||||||
if style is None:
|
if style is None:
|
||||||
return f"<t:{int(dt.timestamp())}>"
|
return f"<t:{int(dt.timestamp())}>"
|
||||||
return f"<t:{int(dt.timestamp())}:{style}>"
|
return f"<t:{int(dt.timestamp())}:{style}>"
|
||||||
|
|
||||||
|
|
||||||
def generate_snowflake(dt: Optional[datetime.datetime] = None) -> int:
|
|
||||||
"""Returns a numeric snowflake pretending to be created at the given date but more accurate and random than time_snowflake.
|
|
||||||
If No dt is not passed, it makes one from the current time using utcnow.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
-----------
|
|
||||||
dt: :class:`datetime.datetime`
|
|
||||||
A datetime object to convert to a snowflake.
|
|
||||||
If naive, the timezone is assumed to be local time.
|
|
||||||
|
|
||||||
Returns
|
|
||||||
--------
|
|
||||||
:class:`int`
|
|
||||||
The snowflake representing the time given.
|
|
||||||
"""
|
|
||||||
|
|
||||||
dt = dt or utcnow()
|
|
||||||
return int(dt.timestamp() * 1000 - DISCORD_EPOCH) << 22 | 0x3fffff
|
|
@ -1136,8 +1136,6 @@ Utility Functions
|
|||||||
|
|
||||||
.. autofunction:: discord.utils.as_chunks
|
.. autofunction:: discord.utils.as_chunks
|
||||||
|
|
||||||
.. autofunction:: discord.utils.generate_snowflake
|
|
||||||
|
|
||||||
.. _discord-api-enums:
|
.. _discord-api-enums:
|
||||||
|
|
||||||
Enumerations
|
Enumerations
|
||||||
|
Reference in New Issue
Block a user