summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-25 02:02:15 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-25 02:02:15 +0200
commitacebb98dccbd1335fd0403bdcbc97717138e0aff (patch)
tree6ac75339f5d2c0a4087cc9abf35a867f877ad510 /src/util
parent:pencil: Update readme (diff)
downloadserver-acebb98dccbd1335fd0403bdcbc97717138e0aff.tar.xz
:bug: fix Snowflake process + worker id
Diffstat (limited to 'src/util')
-rw-r--r--src/util/Snowflake.ts7
1 files changed, 4 insertions, 3 deletions
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.`);