This commit is contained in:
66
src/index.ts
66
src/index.ts
@@ -1,47 +1,55 @@
|
||||
import { Client, Events, GatewayIntentBits, Message, Partials } from 'discord.js';
|
||||
import dotenv from 'dotenv';
|
||||
import path from 'path';
|
||||
import loadModulesFromDir from './lib/loadStartupHandlers';
|
||||
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';
|
||||
import { env } from "process";
|
||||
import webserver from "./webserver";
|
||||
dotenv.config();
|
||||
|
||||
const dbclient: mongoDB.MongoClient = new mongoDB.MongoClient(
|
||||
env.MONGO_DB!
|
||||
);
|
||||
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],
|
||||
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}`);
|
||||
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'),
|
||||
];
|
||||
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);
|
||||
}
|
||||
for (const dir of dirs) {
|
||||
await loadModulesFromDir(dir, client);
|
||||
}
|
||||
});
|
||||
|
||||
// Start webserver in the background
|
||||
@@ -50,4 +58,4 @@ webserver().catch(console.error);
|
||||
// Exports
|
||||
export { client, readyClient };
|
||||
|
||||
client.login(process.env.DISCORD_TOKEN);
|
||||
client.login(process.env.DISCORD_TOKEN);
|
||||
|
||||
Reference in New Issue
Block a user