From acebb98dccbd1335fd0403bdcbc97717138e0aff Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Tue, 25 May 2021 02:02:15 +0200 Subject: :bug: fix Snowflake process + worker id --- src/util/Snowflake.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/util') diff --git a/src/util/Snowflake.ts b/src/util/Snowflake.ts index add940f8..e8056fc4 100644 --- a/src/util/Snowflake.ts +++ b/src/util/Snowflake.ts @@ -1,8 +1,9 @@ // @ts-nocheck +import cluster from "cluster"; // https://github.com/discordjs/discord.js/blob/master/src/util/Snowflake.js // Apache License Version 2.0 Copyright 2015 - 2021 Amish Shah -"use strict"; +("use strict"); // Discord epoch (2015-01-01T00:00:00.000Z) @@ -12,8 +13,8 @@ export class Snowflake { static readonly EPOCH = 1420070400000; static INCREMENT = 0n; // max 4095 - static processId = 0n; // max 31 - static workerId = 0n; // max 31 + static processId = BigInt(process.pid % 31); // max 31 + static workerId = BigInt(cluster.worker.id % 31); // max 31 constructor() { throw new Error(`The ${this.constructor.name} class may not be instantiated.`); -- cgit 1.4.1