first commit

This commit is contained in:
Space-Banane
2026-02-22 14:55:10 +01:00
commit 9235748a47
23 changed files with 2343 additions and 0 deletions

53
src/index.ts Normal file
View File

@@ -0,0 +1,53 @@
import { Client, Events, GatewayIntentBits, Message, Partials } from 'discord.js';
import dotenv from 'dotenv';
import path from 'path';
import loadModulesFromDir from './lib/loadStartupHandlers';
import * as mongoDB from "mongodb";
import { env } from 'process';
import webserver from './webserver';
dotenv.config();
const dbclient: mongoDB.MongoClient = new mongoDB.MongoClient(
env.MONGO_DB!
);
const db: mongoDB.Db = dbclient.db(env.DB_NAME!);
export { db, dbclient };
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent,
],
partials: [Partials.Message, Partials.Channel, Partials.Reaction, Partials.User],
});
let readyClient: typeof client | null = null;
client.once(Events.ClientReady, async (rc) => {
readyClient = rc;
console.log(`Logged in as ${rc.user.tag}`);
const dirs = [
path.join(__dirname, 'commands'), // load commands first
path.join(__dirname, 'handlers'),
path.join(__dirname, 'listeners'),
];
for (const dir of dirs) {
await loadModulesFromDir(dir, client);
}
});
// Start webserver in the background
webserver().catch(console.error);
// Exports
export { client, readyClient };
client.login(process.env.DISCORD_TOKEN);