mirror of
https://github.com/MelisaDev/melisa.git
synced 2024-11-11 19:07:28 +03:00
fix(utils): fix snowflakes
This commit is contained in:
parent
e439ed7525
commit
d51d9edee7
1 changed files with 4 additions and 7 deletions
|
@ -19,7 +19,7 @@ class Snowflake(int):
|
||||||
|
|
||||||
_MAX_VALUE: int = 9223372036854775807
|
_MAX_VALUE: int = 9223372036854775807
|
||||||
_MIN_VALUE: int = 0
|
_MIN_VALUE: int = 0
|
||||||
_DISCORD_EPOCH = 1420070400
|
_DISCORD_EPOCH = 1420070400000
|
||||||
|
|
||||||
def __init__(self, _):
|
def __init__(self, _):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
@ -48,10 +48,7 @@ class Snowflake(int):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def timestamp(self) -> float:
|
def timestamp(self) -> float:
|
||||||
"""
|
return self >> 22
|
||||||
Milliseconds since Discord Epoch, the first second of 2015 or 1420070400000.
|
|
||||||
"""
|
|
||||||
return (self >> 22) / 1000 + self._DISCORD_EPOCH
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def worker_id(self) -> int:
|
def worker_id(self) -> int:
|
||||||
|
@ -69,5 +66,5 @@ class Snowflake(int):
|
||||||
return self % 2048
|
return self % 2048
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unix(self) -> int:
|
def unix(self) -> float:
|
||||||
return self.timestamp + 1420070400000
|
return self.timestamp + self._DISCORD_EPOCH
|
||||||
|
|
Loading…
Reference in a new issue