forked from cosmic/scythe
1
0
Fork 0

uptime part 1

This commit is contained in:
rainydevzz 2025-03-20 14:14:00 -07:00
parent 7c3d7623f9
commit 2acd6f20c7
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import { Client, Discord, On, type ArgsOf } from "discordx"; import { Client, Discord, On, type ArgsOf } from "discordx";
import { underageCheck } from "../utils/underage"; import { underageCheck } from "../utils/underage";
import { bumpRemind } from "../utils/bump"; import { bumpRemind } from "../utils/bump";
import {stat, mkdir} from "fs/promises";
@Discord() @Discord()
export class Ready { export class Ready {
@ -10,7 +11,10 @@ export class Ready {
await client.initApplicationCommands(); await client.initApplicationCommands();
await client.guilds.fetch(); await client.guilds.fetch();
const members = client.guilds.cache.get(Bun.env.GUILD!)?.members; 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", "{}"); await Bun.write("bump.json", "{}");
} }
if (members) { if (members) {

View File

@ -5,7 +5,7 @@ import { sleep } from "./underage";
export const bumpRemind = async (client: Client) => { export const bumpRemind = async (client: Client) => {
while (true) { while (true) {
await sleep(5000); 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); const data = JSON.parse(f);
if (data["bump"]) { if (data["bump"]) {
if (Date.now() - data["bump"] >= 60 * 120 * 1000) { if (Date.now() - data["bump"] >= 60 * 120 * 1000) {