// 起動チェック
import Check from "./checks/main.js";
(async () => {
  await Check();
})();

//　定期実行読み込み
import * as cron from "node-cron";

// 機能読み込み
import timeNotice from "./scripts/timeNotice.js";
import { weatherNotice } from "./scripts/weatherNotice.js";
import earthquakeNotice from "./scripts/earthquakeNotice.js";
import EventDays from "./scripts/eventday.js";
import Commands from "./scripts/commands/main.js";

// その他機能
import asciiArt from "./scripts/asciiart.js";
asciiArt();
import successExit from "./scripts/successExit.js";
successExit();

// 地震情報観測開始
earthquakeNotice();

// 時報(1時間/1回)
cron.schedule("0 * * * *", () => {
  timeNotice();
});

// コマンド(10分/1回)
cron.schedule("*/10 * * * *", () => {
  Commands();
});

// 祝日などお知らせ(毎日0:00)
cron.schedule("0 0 * * *", () => {
  EventDays();
});

// 天気お知らせ(毎日7:00)
import { setTimeout } from "timers";
cron.schedule("0 7 * * *", () => {
  setTimeout(() => {
    weatherNotice();
  }, 100);
});

// 管理パネル
import AdminPanel from "./panel/main.js";
import { styleText } from "util";
(async () => {
  await AdminPanel();
})();

// 起動表示
console.log("BOTサーバーが起動しました");

import config from "./config.js";
if (config.debug !== undefined) {
  process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
  console.log(styleText(["bgRed", "cyan", "bold"], "デバッグモードで起動中"));
}
