2023-01-17 23:11:22 +01:00
|
|
|
import loadClient, { quit } from "./utils/client";
|
|
|
|
import loadEvents from "./events/loader";
|
|
|
|
import loadModals from "./modals/loader";
|
|
|
|
import loadButtons from "./buttons/loader";
|
|
|
|
import loadCommands from "./commands/loader";
|
2022-07-20 23:01:47 +02:00
|
|
|
|
2023-01-17 23:11:22 +01:00
|
|
|
import { logStart } from "./utils/misc";
|
2022-07-20 23:47:41 +02:00
|
|
|
|
2022-07-22 11:46:47 +02:00
|
|
|
/** Run the bot. */
|
2022-07-20 23:01:47 +02:00
|
|
|
const run = async () => {
|
2023-01-17 23:11:22 +01:00
|
|
|
console.log("Starting Botanique...");
|
2022-07-20 23:01:47 +02:00
|
|
|
|
2023-01-17 23:11:22 +01:00
|
|
|
// Load .env if not in prod
|
|
|
|
if (process.env.NODE_ENV !== "production") {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
// @ts-ignore
|
|
|
|
(await import("dotenv")).config({ path: "./config/.env" });
|
|
|
|
}
|
2022-07-20 23:01:47 +02:00
|
|
|
|
2023-01-17 23:11:22 +01:00
|
|
|
// Client Discord.JS
|
|
|
|
const client_name = "Client";
|
|
|
|
await loadClient()
|
|
|
|
.then(async (client) => {
|
|
|
|
// Events Discord.JS
|
|
|
|
const events_name = "Events";
|
|
|
|
await loadEvents(client)
|
|
|
|
.then(() => console.log(logStart(events_name, true)))
|
|
|
|
.catch((err) => {
|
|
|
|
console.error(err);
|
|
|
|
throw logStart(events_name, false);
|
|
|
|
});
|
2022-07-20 23:01:47 +02:00
|
|
|
|
2023-01-17 23:11:22 +01:00
|
|
|
// Connect the bot to Discord.com
|
|
|
|
await client.login(client.config.token_discord);
|
2022-07-20 23:01:47 +02:00
|
|
|
|
2023-01-17 23:11:22 +01:00
|
|
|
// Modals Discord.JS
|
|
|
|
const modals_name = "Modals";
|
|
|
|
await loadModals(client)
|
|
|
|
.then(() => console.log(logStart(modals_name, true)))
|
|
|
|
.catch((err) => {
|
|
|
|
console.error(err);
|
|
|
|
throw logStart(modals_name, false);
|
|
|
|
});
|
2023-01-17 12:15:14 +01:00
|
|
|
|
2023-01-17 23:11:22 +01:00
|
|
|
// Buttons Discord.JS
|
|
|
|
const buttons_name = "Buttons";
|
|
|
|
await loadButtons(client)
|
|
|
|
.then(() => console.log(logStart(buttons_name, true)))
|
|
|
|
.catch((err) => {
|
|
|
|
console.error(err);
|
|
|
|
throw logStart(buttons_name, false);
|
|
|
|
});
|
2023-01-17 12:15:14 +01:00
|
|
|
|
2023-01-17 23:11:22 +01:00
|
|
|
// Commands Slash Discord.JS
|
|
|
|
const commands_name = "Commands";
|
|
|
|
await loadCommands(client)
|
|
|
|
.then(() => console.log(logStart(commands_name, true)))
|
|
|
|
.catch((err) => {
|
|
|
|
console.error(err);
|
|
|
|
throw logStart(commands_name, false);
|
|
|
|
});
|
2022-07-20 23:01:47 +02:00
|
|
|
|
2023-01-17 23:11:22 +01:00
|
|
|
console.log(logStart(client_name, true));
|
|
|
|
console.log(`Botanique "${client.user?.username}" v${client.config.version} started!`);
|
2023-01-17 12:15:14 +01:00
|
|
|
|
2023-01-17 23:11:22 +01:00
|
|
|
// ^C
|
|
|
|
process.on("SIGINT", () => quit(client));
|
2023-01-17 12:15:14 +01:00
|
|
|
|
2023-01-17 23:11:22 +01:00
|
|
|
// Container force closed
|
|
|
|
process.on("SIGTERM", () => quit(client));
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
console.error(err);
|
|
|
|
throw logStart(client_name, false);
|
|
|
|
});
|
2022-07-20 23:01:47 +02:00
|
|
|
};
|
|
|
|
|
2023-01-17 23:11:22 +01:00
|
|
|
run().catch((error) => console.error(error));
|