Skip to content

SnowflakeUtil

classe · Source

A container for useful snowflake-related methods.

Properties

EPOCH

static · readonly

EPOCH: number

Discord's epoch value (2015-01-01T00:00:00.000Z). Source

Methods

generate

static

generate(timestamp?: number | Date): Snowflake

Generates a Discord snowflake. This hardcodes the worker's id as 1 and the process's id as 0. Parameters

NameTypeDescription
timestamp?number | DateTimestamp or date of the snowflake to generate Default: Date.now().

Returns: Snowflake — The generated snowflake Source

deconstruct

static

deconstruct(snowflake: Snowflake): DeconstructedSnowflake

Deconstructs a Discord snowflake. Parameters

NameTypeDescription
snowflakeSnowflakeSnowflake to deconstruct

Returns: DeconstructedSnowflakeSource

timestampFrom

static

timestampFrom(snowflake: Snowflake): number

Retrieves the timestamp field's value from a Discord snowflake. Parameters

NameTypeDescription
snowflakeSnowflakeSnowflake to get the timestamp value from

Returns: numberSource

Unofficial software. Not affiliated with or supported by Discord.