Snowflake

public struct Snowflake

The stored type of a Discord Snowflake ID.

  • Discord’s epoch

    Declaration

    Swift

    public static let epoch = Date(timeIntervalSince1970: 1420070400)
  • Number of generated ID’s for the process

    Declaration

    Swift

    public var numberInProcess: Int
  • Discord’s internal process under worker that generated this snowflake

    Declaration

    Swift

    public var processId: Int
  • The internal value storage for a snowflake

    Declaration

    Swift

    public let rawValue: UInt64
  • Time when snowflake was created

    Declaration

    Swift

    public var timestamp: Date
  • Discord’s internal worker ID that generated this snowflake

    Declaration

    Swift

    public var workerId: Int
  • Initialize from a UInt64

    Declaration

    Swift

    public init(_ snowflake: UInt64)
  • Initialize from any type Currently supports:

    • String

    Declaration

    Swift

    public init?(_ any: Any?)
  • Creates a fake snowflake that would have been created at the specified date Useful for things like the messages before/after/around endpoint

    Declaration

    Swift

    public static func fakeSnowflake(date: Date) -> Snowflake?

    Return Value

    A fake snowflake with the specified date, or nil if the specified date will not make a valid snowflake

  • Declaration

    Swift

    public typealias IntegerLiteralType = UInt64
  • Initialize from an integer literal

    Declaration

    Swift

    public init(integerLiteral value: UInt64)
  • Description for string Conversion

    Declaration

    Swift

    public var description: String
  • Declaration

    Swift

    public typealias RawValue = UInt64
  • Init for rawValue conformance

    Declaration

    Swift

    public init(rawValue: UInt64)
  • Used to compare Snowflakes (which is useful because a greater Snowflake was made later)

    Declaration

    Swift

    public static func <(lhs: Snowflake, rhs: Snowflake) -> Bool
  • The hash value of the Snowflake

    Declaration

    Swift

    public var hashValue: Int