Allow converting a Timestamp back into a snowflake ID #3423
Closed
inklesspen
started this conversation in
Ideas
Replies: 1 comment 1 reply
|
Since the next branch no longer uses NonZeroU64, passing 0 for "the beginning of time" is no longer a problem there. If anyone would be willing to convert this discussion into an issue, I'd be happy to send a PR for it. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
According to the API docs, for timestamps within the legal range, you can convert them into a snowflake ID as
(timestamp_ms - DISCORD_EPOCH) << 22. This is useful for pagination; you can search for messages before or after a specific time.In my project I've currently done a very half-assed version of this:
Additionally, you can pass 0 as the snowflake for "the beginning of time"; however this would seem to pose a larger problem due to the snowflake ID types relying on NonZeroU64.
All reactions