2022-09-29 04:38:19 +00:00
|
|
|
import { activityChanger, checkBroadcast } from "../utils/misc.js";
|
|
|
|
import { send } from "../utils/handler.js";
|
|
|
|
import { generateList, createPage } from "../utils/help.js";
|
|
|
|
import { logger } from "../utils/logger.js";
|
|
|
|
import { readFileSync } from "fs";
|
|
|
|
|
|
|
|
const { types } = JSON.parse(readFileSync(new URL("../config/commands.json", import.meta.url)));
|
2022-10-01 17:02:18 +00:00
|
|
|
let ready = false;
|
2022-09-29 04:38:19 +00:00
|
|
|
|
|
|
|
export default async (client) => {
|
2022-10-01 17:02:18 +00:00
|
|
|
if (ready) return;
|
|
|
|
|
|
|
|
// send slash command data
|
2022-09-29 04:38:19 +00:00
|
|
|
if (types.application) {
|
|
|
|
try {
|
|
|
|
await send(client);
|
|
|
|
} catch (e) {
|
|
|
|
logger.log("error", e);
|
|
|
|
logger.log("error", "Failed to send command data to Discord, slash/message commands may be unavailable.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// generate docs
|
|
|
|
if (process.env.OUTPUT && process.env.OUTPUT !== "") {
|
|
|
|
generateList();
|
|
|
|
await createPage(process.env.OUTPUT);
|
|
|
|
logger.log("info", "The help docs have been generated.");
|
|
|
|
}
|
|
|
|
|
|
|
|
checkBroadcast(client);
|
|
|
|
activityChanger(client);
|
2022-10-01 17:02:18 +00:00
|
|
|
|
|
|
|
ready = true;
|
2022-09-29 04:38:19 +00:00
|
|
|
|
|
|
|
logger.log("info", "Started esmBot.");
|
|
|
|
};
|