old-automod/bot/src/index.ts

73 lines
2.4 KiB
TypeScript
Raw Normal View History

2022-01-04 23:05:52 +00:00
import { config } from 'dotenv';
config();
2021-10-08 21:36:46 +00:00
import logger from './bot/logger';
import AutomodClient, { login } from './struct/AutomodClient';
2022-07-16 18:25:13 +00: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 12:52:07 +00: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 21:36:46 +00:00
logger.info('Initializing client');
let db = MongoDB();
let client = new AutomodClient({
2022-04-09 15:25:27 +00:00
// pongTimeout: 10,
// onPongTimeout: 'RECONNECT',
fixReplyCrash: true,
2022-04-30 09:25:24 +00:00
messageTimeoutFix: true,
apiURL: process.env.API_URL,
2022-05-03 05:53:42 +00:00
messageRateLimiter: true,
}, db);
2021-10-08 21:36:46 +00:00
login(client);
2022-04-09 11:03:12 +00: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 11:48:42 +00:00
BRIDGE_CONFIG: db.get<BridgeConfig>('bridge_config'),
2022-04-30 21:14:48 +00:00
BRIDGED_MESSAGES: db.get<BridgedMessage>('bridged_messages'),
2022-04-24 11:48:42 +00:00
BRIDGE_REQUESTS: db.get<BridgeRequest>('bridge_requests'),
2022-04-09 11:03:12 +00:00
}
export { client, dbs }
2021-10-08 21:36:46 +00:00
2022-05-06 19:50:51 +00: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 18:25:13 +00: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 21:37:59 +00:00
import('./bot/modules/api_communication');
2022-02-12 14:25:24 +00:00
import('./bot/modules/metrics');
import('./bot/modules/bot_status');
import('./bot/modules/fetch_all');
import('./bot/modules/raid_detection');
})();