snowflake is a golang library for parsing snowflake IDs from discord.
This package provides a custom snowflake.ID
type which has various utility methods for parsing discord snowflakes.
go get github.com/disgoorg/snowflake/v2
id := snowflake.ID(123456789012345678)
// deconstructs the snowflake ID into its components timestamp, worker ID, process ID, and increment
id.Deconstruct()
// the time.Time when the snowflake ID was generated
id.Time()
// the worker ID which the snowflake ID was generated
id.WorkerID()
// the process ID which the snowflake ID was generated
id.ProcessID()
// tje sequence when the snowflake ID was generated
id.Sequence()
// returns the string representation of the snowflake ID
id.String()
// returns a new snowflake ID with worker ID, process ID, and sequence set to 0
// this can be used for various pagination requests to the discord api
id := snowflake.New(time.Now())
// returns a snowflake ID from an environment variable
id := snowflake.GetEnv("guild_id")
// returns a snowflake ID from an environment variable and a bool indicating if the key was found
id, found := snowflake.LookupEnv("guild_id")
// returns the string as a snowflake ID or an error
id, err := snowflake.Parse("123456789012345678")
// returns the string as a snowflake ID or panics if an error occurs
id := snowflake.MustParse("123456789012345678")