From 33363f64fc29961c3262054a24cc717b18583b96 Mon Sep 17 00:00:00 2001 From: Slincnik Date: Thu, 16 Jan 2025 18:23:03 +0300 Subject: [PATCH] fix(models): birthdate on user has maybe null --- src/helpers/tasks/birthdays.ts | 2 +- src/models/UserModel.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/tasks/birthdays.ts b/src/helpers/tasks/birthdays.ts index 752fea19..2dab5e60 100644 --- a/src/helpers/tasks/birthdays.ts +++ b/src/helpers/tasks/birthdays.ts @@ -35,7 +35,7 @@ export const data = { const user = users.find(u => u.id === userID); if (!user) return; - const userData = new Date(user.birthdate).getFullYear() <= 1970 ? new Date(user.birthdate * 1000) : new Date(user.birthdate); + const userData = new Date(user.birthdate!).getFullYear() <= 1970 ? new Date(user.birthdate! * 1000) : new Date(user.birthdate!); const userYear = userData.getFullYear(); const userMonth = userData.getMonth(); const userDate = userData.getDate(); diff --git a/src/models/UserModel.ts b/src/models/UserModel.ts index 8a086ceb..e482c52c 100644 --- a/src/models/UserModel.ts +++ b/src/models/UserModel.ts @@ -11,7 +11,7 @@ interface IUserSchema extends Document { id: string; rep: number; bio: string; - birthdate: number; + birthdate: number | null; lover: string; registeredAt: number; achievements: {