should work with utils.
This commit is contained in:
@ -1034,6 +1034,7 @@ def format_dt(dt: datetime.datetime, /, style: Optional[TimestampStyle] = None)
|
|||||||
|
|
||||||
def generate_snowflake(dt: Optional[datetime.datetime] = None) -> int:
|
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.
|
"""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
|
Parameters
|
||||||
-----------
|
-----------
|
||||||
@ -1046,17 +1047,6 @@ def generate_snowflake(dt: Optional[datetime.datetime] = None) -> int:
|
|||||||
:class:`int`
|
:class:`int`
|
||||||
The snowflake representing the time given.
|
The snowflake representing the time given.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
dt = dt or utcnow()
|
dt = dt or utcnow()
|
||||||
return int(dt.timestamp() * 1000 - DISCORD_EPOCH) << 22 | 0x3fffff
|
return int(dt.timestamp() * 1000 - DISCORD_EPOCH) << 22 | 0x3fffff
|
||||||
|
|
||||||
|
|
||||||
def quick_snowflake() -> int:
|
|
||||||
"""A helper function to return a snowflake from the current UTC time with some randomness to make it more unique.
|
|
||||||
|
|
||||||
Returns
|
|
||||||
--------
|
|
||||||
:class:`int`
|
|
||||||
The snowflake generated from the current time using utcnow.
|
|
||||||
"""
|
|
||||||
|
|
||||||
return int(utcnow().timestamp() * 1000 - DISCORD_EPOCH) << 22 | 0x3fffff
|
|
Reference in New Issue
Block a user