Class Snowflake
- Namespace
- NetCord
- Assembly
- NetCord.dll
Provides utilities for creating, parsing and extracting values from snowflake identifiers.
public static class Snowflake
- Inheritance
-
Snowflake
- Inherited Members
Methods
Create(DateTimeOffset)
Creates a snowflake.
public static ulong Create(DateTimeOffset timestamp)
Parameters
timestamp
DateTimeOffsetThe timestamp at which the snowflake was created. Sub-millisecond precision is truncated.
Returns
- ulong
The created snowflake.
Create(DateTimeOffset, byte, byte, ushort)
Creates a snowflake.
public static ulong Create(DateTimeOffset timestamp, byte internalWorkerId, byte internalProcessId, ushort increment)
Parameters
timestamp
DateTimeOffsetThe timestamp at which the snowflake was created. Sub-millisecond precision is truncated.
internalWorkerId
byteThe ID of the internal worker that created the snowflake. Must be in range 0-31.
internalProcessId
byteThe ID of the internal process that created the snowflake. Must be in range 0-31.
increment
ushortThe increment value for the snowflake. Must be in range 0-4095.
Returns
- ulong
The created snowflake.
Create(long)
Creates a snowflake.
public static ulong Create(long timestamp)
Parameters
timestamp
longThe timestamp at which the snowflake was created, in Unix time milliseconds.
Returns
- ulong
The created snowflake.
Create(long, byte, byte, ushort)
Creates a snowflake.
public static ulong Create(long timestamp, byte internalWorkerId, byte internalProcessId, ushort increment)
Parameters
timestamp
longThe timestamp at which the snowflake was created, in Unix time milliseconds.
internalWorkerId
byteThe ID of the internal worker that created the snowflake. Must be in range 0-31.
internalProcessId
byteThe ID of the internal process that created the snowflake. Must be in range 0-31.
increment
ushortThe increment value for the snowflake. Must be in range 0-4095.
Returns
- ulong
The created snowflake.
CreateUnsafe(DateTimeOffset)
Creates a snowflake. Skips validation.
public static ulong CreateUnsafe(DateTimeOffset timestamp)
Parameters
timestamp
DateTimeOffsetThe timestamp at which the snowflake was created. Sub-millisecond precision is truncated.
Returns
- ulong
The created snowflake.
CreateUnsafe(DateTimeOffset, byte, byte, ushort)
Creates a snowflake. Skips validation.
public static ulong CreateUnsafe(DateTimeOffset timestamp, byte internalWorkerId, byte internalProcessId, ushort increment)
Parameters
timestamp
DateTimeOffsetThe timestamp at which the snowflake was created. Sub-millisecond precision is truncated.
internalWorkerId
byteThe ID of the internal worker that created the snowflake. Must be in range 0-31.
internalProcessId
byteThe ID of the internal process that created the snowflake. Must be in range 0-31.
increment
ushortThe increment value for the snowflake. Must be in range 0-4095.
Returns
- ulong
The created snowflake.
CreateUnsafe(long)
Creates a snowflake. Skips validation.
public static ulong CreateUnsafe(long timestamp)
Parameters
timestamp
longThe timestamp at which the snowflake was created, in Unix time milliseconds.
Returns
- ulong
The created snowflake.
CreateUnsafe(long, byte, byte, ushort)
Creates a snowflake. Skips validation.
public static ulong CreateUnsafe(long timestamp, byte internalWorkerId, byte internalProcessId, ushort increment)
Parameters
timestamp
longThe timestamp at which the snowflake was created, in Unix time milliseconds.
internalWorkerId
byteThe ID of the internal worker that created the snowflake. Must be in range 0-31.
internalProcessId
byteThe ID of the internal process that created the snowflake. Must be in range 0-31.
increment
ushortThe increment value for the snowflake. Must be in range 0-4095.
Returns
- ulong
The created snowflake.
Increment(ulong)
Gets the increment value for the snowflake.
public static ushort Increment(ulong id)
Parameters
id
ulongThe snowflake identifier.
Returns
- ushort
The increment value for the snowflake.
InternalProcessId(ulong)
Gets the ID of the internal process that created the snowflake.
public static byte InternalProcessId(ulong id)
Parameters
id
ulongThe snowflake identifier.
Returns
- byte
The ID of the internal process that created the snowflake.
InternalWorkerId(ulong)
Gets the ID of the internal worker that created the snowflake.
public static byte InternalWorkerId(ulong id)
Parameters
id
ulongThe snowflake identifier.
Returns
- byte
The ID of the internal worker that created the snowflake.
Parse(ReadOnlySpan<byte>)
Parses a snowflake from a span of UTF-8 characters.
public static ulong Parse(ReadOnlySpan<byte> value)
Parameters
value
ReadOnlySpan<byte>The span of UTF-8 characters to parse.
Returns
- ulong
The resulting snowflake identifier.
Parse(ReadOnlySpan<char>)
Parses a snowflake from a span of characters.
public static ulong Parse(ReadOnlySpan<char> value)
Parameters
value
ReadOnlySpan<char>The span of characters to parse.
Returns
- ulong
The resulting snowflake identifier.
ShardId(ulong, int)
Gets the ID of the shard that the guild belongs to.
public static int ShardId(ulong guildId, int shardCount)
Parameters
Returns
- int
The ID of the shard that the guild belongs to.
Timestamp(ulong)
Gets the timestamp at which the snowflake was created.
public static DateTimeOffset Timestamp(ulong id)
Parameters
id
ulongThe snowflake identifier.
Returns
- DateTimeOffset
The timestamp at which the snowflake was created.
TryParse(ReadOnlySpan<byte>, out ulong)
Tries to parse a snowflake from a span of UTF-8 characters.
public static bool TryParse(ReadOnlySpan<byte> value, out ulong id)
Parameters
value
ReadOnlySpan<byte>The span of UTF-8 characters to parse.
id
ulongThe resulting snowflake identifier.
Returns
TryParse(ReadOnlySpan<char>, out ulong)
Tries to parse a snowflake from a span of characters.
public static bool TryParse(ReadOnlySpan<char> value, out ulong id)
Parameters
value
ReadOnlySpan<char>The span of characters to parse.
id
ulongThe resulting snowflake identifier.