AutoMod/bot/src/index.ts

73 lines
2.4 KiB
TypeScript
Raw Normal View History

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';
2022-07-16 20:25:13 +02:00
import MongoDB, { databaseMigrations } from './bot/db';
import DbUser from 'automod/dist/types/DbUser';
import ServerConfig from 'automod/dist/types/ServerConfig';
import Infraction from 'automod/dist/types/antispam/Infraction';
import PendingLogin from 'automod/dist/types/PendingLogin';
import TempBan from 'automod/dist/types/TempBan';
2022-05-03 14:52:07 +02:00
import { VoteEntry } from './bot/commands/moderation/votekick';
import BridgeRequest from 'automod/dist/types/BridgeRequest';
import BridgeConfig from 'automod/dist/types/BridgeConfig';
import BridgedMessage from 'automod/dist/types/BridgedMessage';
2021-10-08 23:36:46 +02:00
logger.info('Initializing client');
let db = MongoDB();
let client = new AutomodClient({
2022-04-09 17:25:27 +02:00
// pongTimeout: 10,
// onPongTimeout: 'RECONNECT',
fixReplyCrash: true,
2022-04-30 11:25:24 +02:00
messageTimeoutFix: true,
apiURL: process.env.API_URL,
2022-05-03 07:53:42 +02:00
messageRateLimiter: true,
}, 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'),
2022-04-24 13:48:42 +02:00
BRIDGE_CONFIG: db.get<BridgeConfig>('bridge_config'),
2022-04-30 23:14:48 +02:00
BRIDGED_MESSAGES: db.get<BridgedMessage>('bridged_messages'),
2022-04-24 13:48:42 +02:00
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
2022-05-06 21:50:51 +02:00
logger.info(`\
_ _ __ __ _
/ \\ _ _| |_ ___ | \\/ | ___ __| |
/ _ \\ | | | | __|/ _ \\| |\\/| |/ _ \\ / _\` |
/ ___ \\| |_| | |_| (_) | | | | (_) | (_| |
/_/ \\_\\\\__,_|\\__|\\___/|_| |_|\\___/ \\__,_|
`);
(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!');
2022-07-16 20:25:13 +02:00
logger.info('Running database migrations...');
await databaseMigrations();
// Load modules
import('./bot/modules/command_handler');
import('./bot/modules/mod_logs');
import('./bot/modules/event_handler');
import('./bot/modules/tempbans');
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');
import('./bot/modules/bot_status');
import('./bot/modules/fetch_all');
import('./bot/modules/raid_detection');
})();