Snowflake class
A unique ID used to identify objects in the API.
Snowflakes are generally unique across the API except in some cases where children share their parent's IDs.
{@template snowflake_ordering} Snowflakes are ordered first by their timestamp, then by workerId, processId and increment. The last three fields are only used internally by Discord so the only ordering visible through the API is by timestamp.
External references:
- Discord API Reference: https://discord.com/developers/docs/reference#snowflakes {@endtemplate}
- Implemented types
Constructors
- Snowflake(int value)
-
Create a new snowflake from an integer value.
const
- Snowflake.firstBulk()
-
Create a snowflake representing the oldest time at which bulk delete operations will work.
factory
- Snowflake.fromDateTime(DateTime dateTime)
-
Create a snowflake with a timestamp equal to
dateTime
.factory - Snowflake.now()
-
Create a snowflake with a timestamp equal to the current time.
factory
- Snowflake.parse(Object value)
-
Parse a string or integer value to a snowflake.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- increment → int
-
The internal increment value for this snowflake.
no setter
- isZero → bool
-
Whether this snowflake has a value of
0
.no setter - millisecondsSinceEpoch → int
-
The number of milliseconds since the epoch.
no setter
- processId → int
-
The internal process ID for this snowflake.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- timestamp → DateTime
-
The time at which this snowflake was created.
no setter
- value → int
-
The value of this snowflake.
final
- workerId → int
-
The internal worker ID for this snowflake.
no setter
Methods
-
compareTo(
Snowflake other) → int -
Compares this object to another object.
override
-
isAfter(
Snowflake other) → bool -
Return
true
if this snowflake has a timestamp afterother
's timestamp. -
isAtSameMomentAs(
Snowflake other) → bool -
Return
true
if this snowflake has a timestamp at the same time asother
's timestamp. -
isBefore(
Snowflake other) → bool -
Return
true
if this snowflake has a timestamp beforeother
's timestamp. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator +(
Duration duration) → Snowflake -
Return a snowflake
duration
after this snowflake. -
operator -(
Duration duration) → Snowflake -
Return a snowflake
duration
before this snowflake. -
operator <(
Snowflake other) → bool -
Whether this snowflake is before
other
. -
operator ==(
Object other) → bool -
The equality operator.
override
-
operator >(
Snowflake other) → bool -
Whether this snowflake is after
other
.
Static Properties
Constants
- bulkDeleteLimit → const Duration
- The duration after which bulk delete operations are no longer valid.
- zero → const Snowflake
- A snowflake with a value of 0.