37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { Client, GatewayIntentBits, Partials } from 'discord.js';
|
|
import { env } from './config/env.js';
|
|
import { CommandHandler } from './services/commandHandler.js';
|
|
import { EventHandlerService } from './services/eventHandler.js';
|
|
import { logger } from './utils/logger.js';
|
|
import { context } from './config/context.js';
|
|
import { createWebServer } from './web/server.js';
|
|
|
|
async function bootstrap() {
|
|
const client = new Client({
|
|
intents: [
|
|
GatewayIntentBits.Guilds,
|
|
GatewayIntentBits.GuildMembers,
|
|
GatewayIntentBits.GuildMessages,
|
|
GatewayIntentBits.MessageContent,
|
|
GatewayIntentBits.GuildVoiceStates
|
|
],
|
|
partials: [Partials.Channel, Partials.GuildMember, Partials.Message]
|
|
});
|
|
|
|
const commandHandler = new CommandHandler(client);
|
|
context.commandHandler = commandHandler;
|
|
|
|
await commandHandler.loadCommands();
|
|
await commandHandler.registerSlashCommands();
|
|
|
|
const eventHandler = new EventHandlerService(client);
|
|
await eventHandler.loadEvents();
|
|
|
|
client.login(env.token);
|
|
|
|
const app = createWebServer();
|
|
app.listen(env.port, () => logger.info(`Webserver läuft auf Port ${env.port}`));
|
|
}
|
|
|
|
bootstrap().catch((err) => logger.error('Bootstrap failed', err));
|