feat: actually fix the birthday command

This commit is contained in:
2022-11-18 17:53:00 +01:00
parent c9fa587ec8
commit 7a27598763
2 changed files with 8 additions and 21 deletions

View File

@@ -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) {
}
});

View File

@@ -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()
}
})
})
}