{"size": 1565, "ext": "js", "max_stars_repo_path": "src/instance.js", "max_stars_repo_name": "blackcatbot/blackcat", "max_stars_repo_stars_event_min_datetime": "2021-09-26T05:04:06.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T13:14:51.000Z", "max_issues_repo_path": "src/instance.js", "max_issues_repo_name": "blackcatbot/blackcat", "max_issues_repo_issues_event_min_datetime": "2021-09-12T06:18:28.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-25T09:29:39.000Z", "max_forks_repo_path": "src/instance.js", "max_forks_repo_name": "blackcatbot/blackcat", "max_forks_repo_forks_event_min_datetime": "2021-10-03T22:05:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-26T16:32:21.000Z"}
{"max_stars_count": 10, "max_issues_count": 13, "max_forks_count": 6, "avg_line_length": 23.0147058824, "max_line_length": 64, "alphanum_fraction": 0.6261980831}
import dotenv from "dotenv";
dotenv.config();

import Discord from "discord.js";
import fs from "node:fs";

import log from "./logger.js";
import configReslover from "./util/configReslover.js";

const config = await configReslover();
const client = new Discord.Client({
  intents: [
    Discord.Intents.FLAGS.GUILDS,
    Discord.Intents.FLAGS.GUILD_VOICE_STATES,
  ],
  allowedMentions: {
    parse: ["users"],
    repliedUser: false,
  },
  presence: {
    status: "idle",
    activities: [
      {
        name: "載入中... 請稍等",
        type: "COMPETING",
      },
    ],
  },
});

client.commands = new Discord.Collection();
client.players = new Map();
client.config = config;
client.logger = log;

let commandFiles = fs
  .readdirSync("./src/commands/")
  .filter((file) => file.endsWith(".js"));
commandFiles.forEach(async (cmd) => {
  let command = (await import(`./commands/${cmd}`)).default;
  client.commands.set(command.data.name, command);
});

const eventFiles = fs
  .readdirSync("./src/events")
  .filter((file) => file.endsWith(".js"));
eventFiles.forEach(async (event) => {
  const eventFile = (await import(`./events/${event}`)).default;
  if (eventFile.once) {
    client.once(eventFile.event, (...args) =>
      eventFile.run(client, ...args),
    );
  } else {
    client.on(eventFile.event, (...args) =>
      eventFile.run(client, ...args),
    );
  }
});

client.login(config.token);

process.on("message", (message) => {
  if (message.type === "shardId") {
    client.shardId = message.value;
    log.info(`分片已接收到ID ${message.value}`);
  }
});
