2022-04-04 20:14:12 +00:00
|
|
|
import { config } from 'dotenv';
|
|
|
|
import Log75, { LogLevel } from 'log75';
|
|
|
|
import { getDb } from './db';
|
|
|
|
import { login as loginRevolt } from './revolt/client';
|
|
|
|
import { login as loginDiscord } from './discord/client';
|
2022-04-05 08:31:02 +00:00
|
|
|
import { ICollection } from 'monk';
|
|
|
|
import BridgeConfig from './types/BridgeConfig';
|
|
|
|
import BridgedMessage from './types/BridgedMessage';
|
2022-04-24 11:48:42 +00:00
|
|
|
import BridgeRequest from './types/BridgeRequest';
|
2022-05-01 12:34:49 +00:00
|
|
|
import DiscordBridgedEmoji from './types/DiscordBridgedEmoji';
|
2022-04-04 20:14:12 +00:00
|
|
|
|
|
|
|
config();
|
|
|
|
|
|
|
|
const logger: Log75 = new (Log75 as any).default(LogLevel.Debug);
|
|
|
|
const db = getDb();
|
2022-04-05 08:31:02 +00:00
|
|
|
const BRIDGED_MESSAGES: ICollection<BridgedMessage> = db.get('bridged_messages');
|
|
|
|
const BRIDGE_CONFIG: ICollection<BridgeConfig> = db.get('bridge_config');
|
2022-04-24 11:48:42 +00:00
|
|
|
const BRIDGE_REQUESTS: ICollection<BridgeRequest> = db.get('bridge_requests');
|
2022-05-01 12:34:49 +00:00
|
|
|
const BRIDGED_EMOJIS: ICollection<DiscordBridgedEmoji> = db.get('bridged_emojis');
|
2022-04-04 20:14:12 +00:00
|
|
|
|
|
|
|
for (const v of [ 'REVOLT_TOKEN', 'DISCORD_TOKEN', 'DB_STRING' ]) {
|
|
|
|
if (!process.env[v]) {
|
|
|
|
logger.error(`Env var $${v} expected but not set`);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
(async () => {
|
2022-04-28 05:31:02 +00:00
|
|
|
import('./metrics');
|
2022-04-04 20:14:12 +00:00
|
|
|
const [ revolt, discord ] = await Promise.allSettled([
|
|
|
|
loginRevolt(),
|
|
|
|
loginDiscord(),
|
|
|
|
]);
|
|
|
|
})();
|
|
|
|
|
2022-05-01 12:34:49 +00:00
|
|
|
export { logger, db, BRIDGED_MESSAGES, BRIDGE_CONFIG, BRIDGE_REQUESTS, BRIDGED_EMOJIS }
|