import { ActivityType } from "discord.js";
import type { DiscordClient } from "./client";

let timer: Timer;
export const startTimer = (client: DiscordClient, interval: number) => {
  timer = setInterval(async () => {
    const awake = await client.ai.health();
    
    if (!awake) {
      client.user?.setActivity({
        name: "Joel VAKNAR ge honom en minut",
        type: ActivityType.Custom,
      });
    } else {
      clearInterval(timer);
      client.user?.setActivity({
        name: "Joel är FUCKING VAKEN",
        type: ActivityType.Custom,
      });
      console.log("joel has risen");
    }
  }, interval);
};

let sleepTimer: Timer;
export const setSleepTimer = (client: DiscordClient) => {
  clearTimeout(sleepTimer);
  sleepTimer = setTimeout(() => {
    client.user?.setActivity({
      type: ActivityType.Custom,
      name: "Joel SOVER fucking VÄCK HONOM",
    });
  }, 15 * 60 * 1000);
};
