From 7a27598763da6ec2e11d876754df1528f5325ada Mon Sep 17 00:00:00 2001 From: SrIzan10 <66965250+SrIzan10@users.noreply.github.com> Date: Fri, 18 Nov 2022 17:53:00 +0100 Subject: [PATCH] feat: actually fix the birthday command --- commands/handlers/nickname-modal.ts | 14 -------------- util/birthdays.ts | 15 ++++++++------- 2 files changed, 8 insertions(+), 21 deletions(-) delete mode 100644 commands/handlers/nickname-modal.ts diff --git a/commands/handlers/nickname-modal.ts b/commands/handlers/nickname-modal.ts deleted file mode 100644 index 7ac2388..0000000 --- a/commands/handlers/nickname-modal.ts +++ /dev/null @@ -1,14 +0,0 @@ -// import everything -import { commandModule, CommandType } from '@sern/handler' -import { EmbedBuilder } from 'discord.js'; -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" -import { TextChannel, ThreadAutoArchiveDuration, ThreadManager } from "discord.js"; - -export default commandModule({ - type: CommandType.Modal, - //alias : [], - async execute (modal) { - - } -}); \ No newline at end of file diff --git a/util/birthdays.ts b/util/birthdays.ts index 095d0b5..5434e66 100644 --- a/util/birthdays.ts +++ b/util/birthdays.ts @@ -3,17 +3,17 @@ import { Client, TextChannel } from "discord.js"; import db from "../schemas/birthdays.js"; export default async function birthdays(client: Client) { - const fetchallusers = await db.find(); - const filtered = fetchallusers.map((user) => user.id); - for (const user of filtered) { - const finduser = await db.findOne({ id: user }); +db.find({}, (err, user) => { + if (err) throw err + user.map(async user => { + const finduser = await db.findOne({ id: user.id }); async function saveit() { finduser!.alreadysent = false - await finduser!.save() + await finduser!.save() } if (finduser!.date === dayjs().format("D-M")) {} else return if (finduser!.alreadysent === true && dayjs().format('D-M') !== finduser!.date) return saveit() - if (finduser!.alreadysent === true && dayjs().format('D-M') === finduser!.date) return + if (finduser!.alreadysent === true) return const sendtochannel = (await ( await client.guilds.fetch("928018226330337280") ).channels.fetch("1039613653269352449")) as TextChannel; @@ -22,5 +22,6 @@ export default async function birthdays(client: Client) { message.react('<:Pog:1030169609178976346>') finduser!.alreadysent = true await finduser?.save() - } + }) +}) }