Small fix for tag digit and undefined email
This commit is contained in:
parent
6472a9e41b
commit
b8aee9b217
@ -74,7 +74,13 @@ export class Member extends BaseClassWithoutId {
|
|||||||
nick?: string;
|
nick?: string;
|
||||||
|
|
||||||
setNick(val: string) {
|
setNick(val: string) {
|
||||||
if (val && BannedWords.find(val)) throw FieldErrors({ nick: { message: "Bad nickname", code: "INVALID_NICKNAME" } });
|
|
||||||
|
if (val) {
|
||||||
|
val = val.split("\n").join("");
|
||||||
|
val = val.split("\t").join("");
|
||||||
|
if (BannedWords.find(val)) throw FieldErrors({ nick: { message: "Bad nickname", code: "INVALID_NICKNAME" } });
|
||||||
|
}
|
||||||
|
|
||||||
this.nick = val;
|
this.nick = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +69,10 @@ export class User extends BaseClass {
|
|||||||
|
|
||||||
setDiscriminator(val: string) {
|
setDiscriminator(val: string) {
|
||||||
const number = Number(val);
|
const number = Number(val);
|
||||||
|
if (val.length > 4) throw new Error("invalid discriminator");
|
||||||
if (isNaN(number)) throw new Error("invalid discriminator");
|
if (isNaN(number)) throw new Error("invalid discriminator");
|
||||||
if (number <= 0 || number >= 10000) throw new Error("discriminator must be between 1 and 9999");
|
if (number <= 0 || number >= 10000) throw new Error("discriminator must be between 1 and 9999");
|
||||||
|
val = Number(val).toString()
|
||||||
this.discriminator = val.toString().padStart(4, "0");
|
this.discriminator = val.toString().padStart(4, "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,6 +139,11 @@ export class User extends BaseClass {
|
|||||||
@Column({ nullable: true, select: false })
|
@Column({ nullable: true, select: false })
|
||||||
email?: string; // email of the user
|
email?: string; // email of the user
|
||||||
|
|
||||||
|
setEmail(val: string) {
|
||||||
|
if (!val.match(/([a-z\d.-]{3,})@([a-z\d.-]+).([a-z]{2,})/g)) throw FieldErrors({ email: { message: "Invalid email", code: "EMAIL_INVALID" } });
|
||||||
|
this.email = val;
|
||||||
|
}
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
flags: string; // UserFlags
|
flags: string; // UserFlags
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user