2022-01-05 00:05:52 +01:00
|
|
|
import { config } from 'dotenv';
|
|
|
|
config();
|
2021-10-08 23:36:46 +02:00
|
|
|
|
|
|
|
import logger from './bot/logger';
|
|
|
|
import AutomodClient, { login } from './struct/AutomodClient';
|
|
|
|
import MongoDB from './bot/db';
|
2022-04-09 13:03:12 +02:00
|
|
|
import DbUser from './struct/DbUser';
|
|
|
|
import ServerConfig from './struct/ServerConfig';
|
|
|
|
import Infraction from './struct/antispam/Infraction';
|
|
|
|
import PendingLogin from './struct/PendingLogin';
|
|
|
|
import TempBan from './struct/TempBan';
|
|
|
|
import { VoteEntry } from './bot/commands/votekick';
|
|
|
|
import ScannedUser from './struct/ScannedUser';
|
2022-04-24 13:48:42 +02:00
|
|
|
import BridgeRequest from './struct/BridgeRequest';
|
|
|
|
import BridgeConfig from './struct/BridgeConfig';
|
2021-10-08 23:36:46 +02:00
|
|
|
|
|
|
|
logger.info('Initializing client');
|
|
|
|
|
|
|
|
let db = MongoDB();
|
2022-02-05 15:59:45 +01:00
|
|
|
let client = new AutomodClient({
|
2022-04-09 17:25:27 +02:00
|
|
|
// pongTimeout: 10,
|
|
|
|
// onPongTimeout: 'RECONNECT',
|
2022-02-05 15:59:45 +01:00
|
|
|
fixReplyCrash: true,
|
2022-04-30 11:25:24 +02:00
|
|
|
messageTimeoutFix: true,
|
|
|
|
apiURL: process.env.API_URL,
|
2022-02-05 15:59:45 +01:00
|
|
|
}, db);
|
2021-10-08 23:36:46 +02:00
|
|
|
login(client);
|
|
|
|
|
2022-04-09 13:03:12 +02:00
|
|
|
const dbs = {
|
|
|
|
SERVERS: db.get<ServerConfig>('servers'),
|
|
|
|
USERS: db.get<DbUser>('users'),
|
|
|
|
INFRACTIONS: db.get<Infraction>('infractions'),
|
|
|
|
PENDING_LOGINS: db.get<PendingLogin>('pending_logins'),
|
|
|
|
SESSIONS: db.get('sessions'),
|
|
|
|
TEMPBANS: db.get<TempBan>('tempbans'),
|
|
|
|
VOTEKICKS: db.get<VoteEntry>('votekicks'),
|
|
|
|
SCANNED_USERS: db.get<ScannedUser>('scanned_users'),
|
2022-04-24 13:48:42 +02:00
|
|
|
BRIDGE_CONFIG: db.get<BridgeConfig>('bridge_config'),
|
|
|
|
BRIDGE_REQUESTS: db.get<BridgeRequest>('bridge_requests'),
|
2022-04-09 13:03:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export { client, dbs }
|
2021-10-08 23:36:46 +02:00
|
|
|
|
2021-12-05 15:16:41 +01:00
|
|
|
(async () => {
|
|
|
|
// Wait for a database query to succeed before loading the rest
|
|
|
|
logger.info('Connecting to database...');
|
|
|
|
await db.get('servers').findOne({});
|
|
|
|
logger.done('DB ready!');
|
|
|
|
|
|
|
|
// Load modules
|
|
|
|
import('./bot/modules/command_handler');
|
|
|
|
import('./bot/modules/mod_logs');
|
2021-12-06 20:03:17 +01:00
|
|
|
import('./bot/modules/event_handler');
|
|
|
|
import('./bot/modules/tempbans');
|
2021-12-09 22:04:33 +01:00
|
|
|
import('./bot/modules/user_scan');
|
2022-01-22 22:37:59 +01:00
|
|
|
import('./bot/modules/api_communication');
|
2022-02-12 15:25:24 +01:00
|
|
|
import('./bot/modules/metrics');
|
2022-04-09 14:38:27 +02:00
|
|
|
import('./bot/modules/bot_status');
|
|
|
|
import('./bot/modules/fetch_all');
|
2021-12-05 15:16:41 +01:00
|
|
|
})();
|