@pwldev/discord-snowflake
v1.0.4
Published
A single file package to generate, parse, and do more with Discord Snowflake IDs
Maintainers
Readme
Discord Snowflake
An easy to use single file package to generate, parse and do more with Discord Snowflake IDs.
Installation
To install this package with NPM use the command:
npm install @pwldev/discord-snowflakeThis is a hybrid package, so you can import it both ways
import * as Snowflake from "@pwldev/discord-snowflake";
const SnowflakeManager = require("@pwldev/discord-snowflake");Methods
generate
Generates a Snowflake ID using a Unix Timestamp or Date instance.
import * as Snowflake from "@pwldev/discord-snowflake";
const newSnowflake = Snowflake.generate(1679460085433);
console.log(newSnowflake);
// 1087853498709577700getDate
Gets a Snowflake ID's timestamp as a Date instance
import * as Snowflake from "@pwldev/discord-snowflake";
Snowflake.getDate(1087853498709577700)
// DategetIncrement
Gets a Snowflake ID's increment
import * as Snowflake from "@pwldev/discord-snowflake";
Snowflake.getIncrement(1087853498709577700)
// 3769getProcessId
Gets a Snowflake ID's Process ID
import * as Snowflake from "@pwldev/discord-snowflake";
Snowflake.getProcessId(1087853498709577700)
// 3769getTimestamp
Gets a Snowflake ID's Unix Timestamp
import * as Snowflake from "@pwldev/discord-snowflake";
Snowflake.getTimestamp(1087853498709577700)
// 1087853498709577700getWorkerId
Gets a Snowflake ID's Worker ID
import * as Snowflake from "@pwldev/discord-snowflake";
Snowflake.getWorkerId(1087853498709577700)
// 3769parse
Gets all information at once from a Snowflake ID
import * as Snowflake from "@pwldev/discord-snowflake";
Snowflake.parse(1087853498709577700)
// { "increment": 3769, "processId": 3769, "timestamp": 1420096000414, "workerId": 3769 }Links
Created by PwLDev Based on the official Discord API docs.
