fix(utils): fix snowflakes

This commit is contained in:
grey-cat-1908 2023-03-07 18:34:32 +03:00
parent e439ed7525
commit d51d9edee7

View file

@ -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