From 2acd6f20c7118e7dd2ae0717bd91e9ed10d5e198 Mon Sep 17 00:00:00 2001 From: rainydevzz Date: Thu, 20 Mar 2025 14:14:00 -0700 Subject: [PATCH] uptime part 1 --- src/events/ready.ts | 6 +++++- src/utils/bump.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/events/ready.ts b/src/events/ready.ts index a37d6bf..1b04f76 100644 --- a/src/events/ready.ts +++ b/src/events/ready.ts @@ -1,6 +1,7 @@ import { Client, Discord, On, type ArgsOf } from "discordx"; import { underageCheck } from "../utils/underage"; import { bumpRemind } from "../utils/bump"; +import {stat, mkdir} from "fs/promises"; @Discord() export class Ready { @@ -10,7 +11,10 @@ export class Ready { await client.initApplicationCommands(); await client.guilds.fetch(); const members = client.guilds.cache.get(Bun.env.GUILD!)?.members; - if (!(await Bun.file("bump.json").exists())) { + if(!((await stat("data")).isDirectory())) { + await mkdir("data") + } + if (!(await Bun.file("data/bump.json").exists())) { await Bun.write("bump.json", "{}"); } if (members) { diff --git a/src/utils/bump.ts b/src/utils/bump.ts index 9fb27ba..7aae60c 100644 --- a/src/utils/bump.ts +++ b/src/utils/bump.ts @@ -5,7 +5,7 @@ import { sleep } from "./underage"; export const bumpRemind = async (client: Client) => { while (true) { await sleep(5000); - const f = await Bun.file("bump.json").text(); + const f = await Bun.file("data/bump.json").text(); const data = JSON.parse(f); if (data["bump"]) { if (Date.now() - data["bump"] >= 60 * 120 * 1000) {