more error handling

This commit is contained in:
MathMan05 2024-07-30 15:45:26 -05:00
parent ed2bc49b0c
commit b9f1bb5e53
2 changed files with 13 additions and 2 deletions

View file

@ -75,7 +75,13 @@ class SnowFlake {
}
}
getUnixTime() {
return Number((BigInt(this.id) >> 22n) + 1420070400000n);
try {
return Number((BigInt(this.id) >> 22n) + 1420070400000n);
}
catch {
console.error(`The ID is corrupted, it's ${this.id} when it should be some number.`);
return 0;
}
}
toString() {
return this.id;