summary refs log tree commit diff
path: root/src/util/entities
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-10-03 20:29:32 +0200
committerRory& <root@rory.gay>2025-10-04 19:09:25 +0200
commit7d2fd7b4f8d5ab7e27bfbea6a4498edbbaf7df9c (patch)
treee3d81e73541ed6f70521a87ff332e13846646089 /src/util/entities
parentDrop dependency on missing-native-js-functions (diff)
downloadserver-ts-7d2fd7b4f8d5ab7e27bfbea6a4498edbbaf7df9c.tar.xz
Add dotnet-ish Random class
Diffstat (limited to 'src/util/entities')
-rw-r--r--src/util/entities/User.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts

index 2375008e..d1b3c709 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts
@@ -19,7 +19,7 @@ import { Request } from "express"; import { Column, Entity, FindOneOptions, JoinColumn, OneToMany, OneToOne } from "typeorm"; import { Channel, ChannelType, Config, Email, FieldErrors, Snowflake, trimSpecial } from ".."; -import { BitField } from "../util/BitField"; +import { BitField, Random } from "../util"; import { BaseClass } from "./BaseClass"; import { ConnectedAccount } from "./ConnectedAccount"; import { Member } from "./Member"; @@ -284,7 +284,7 @@ export class User extends BaseClass { // randomly generates a discriminator between 1 and 9999 and checks max five times if it already exists // TODO: is there any better way to generate a random discriminator only once, without checking if it already exists in the database? for (let tries = 0; tries < 5; tries++) { - const discriminator = Math.randomIntBetween(1, 9999).toString().padStart(4, "0"); + const discriminator = Random.nextInt(1, 9999).toString().padStart(4, "0"); const exists = await User.findOne({ where: { discriminator, username: username }, select: ["id"],