Botanique/src/load.ts
Mylloon 767612a000
All checks were successful
Publish latest version / build (push) Successful in 2m2s
chore: merge dev to main (#172)
Reviewed-on: #172
Co-authored-by: Mylloon <kennel.anri@tutanota.com>
Co-committed-by: Mylloon <kennel.anri@tutanota.com>
2024-09-18 18:25:03 +02:00

74 lines
2.2 KiB
TypeScript

import loadButtons from "./buttons/loader";
import loadCommands from "./commands/loader";
import loadEvents from "./events/loader";
import loadModals from "./modals/loader";
import loadClient, { quit } from "./utils/client";
import { logStart } from "./utils/misc";
/** Run the bot */
export const run = async (isDev: boolean) => {
console.log("Starting Botanique...");
// Client Discord.JS
const client_name = "Client";
await loadClient(isDev)
.then(async (client) => {
if (isDev) {
// Attach debugging listeners
client.on("debug", console.log).on("warn", console.warn);
}
// Events Discord.JS and Player
const events_name = "Events";
await loadEvents(client, isDev)
.then(() => console.log(logStart(events_name, true)))
.catch((err) => {
console.error(err);
throw logStart(events_name, false);
});
// Connect the bot to Discord.com
await client.login(client.config.token_discord);
// 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);
});
// 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);
});
// 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);
});
console.log(logStart(client_name, true));
console.log(`Botanique "${client.user?.username}" v${client.config.version} started!`);
// ^C
process.on("SIGINT", () => quit(client));
// Container force closed
process.on("SIGTERM", () => quit(client));
})
.catch((err) => {
console.error(err);
throw logStart(client_name, false);
});
};