muse/src/index.ts

39 lines
1 KiB
TypeScript
Raw Normal View History

2020-03-17 01:37:54 +01:00
import makeDir from 'make-dir';
2020-03-17 18:30:27 +01:00
import path from 'path';
import {makeLines} from 'nodesplash';
import container from './inversify.config.js';
import {TYPES} from './types.js';
import Bot from './bot.js';
import {sequelize} from './utils/db.js';
import Config from './services/config.js';
import FileCacheProvider from './services/file-cache.js';
2021-12-26 18:05:56 +01:00
import metadata from '../package.json';
2020-03-09 17:57:39 +01:00
2021-09-20 01:50:25 +02:00
const bot = container.get<Bot>(TYPES.Bot);
2020-10-31 15:42:06 +01:00
(async () => {
// Banner
console.log(makeLines({
user: 'codetheweb',
repository: 'muse',
version: metadata.version,
paypalUser: 'codetheweb',
githubSponsor: 'codetheweb',
madeByPrefix: 'Made with 🎶 by ',
}).join('\n'));
console.log('\n');
2020-03-17 01:37:54 +01:00
// Create data directories if necessary
2021-09-20 01:50:25 +02:00
const config = container.get<Config>(TYPES.Config);
await makeDir(config.DATA_DIR);
await makeDir(config.CACHE_DIR);
await makeDir(path.join(config.CACHE_DIR, 'tmp'));
2020-03-17 01:37:54 +01:00
await sequelize.sync({alter: true});
2020-03-17 01:37:54 +01:00
await container.get<FileCacheProvider>(TYPES.FileCache).cleanup();
2020-05-31 04:37:40 +02:00
await bot.listen();
2020-03-13 04:41:26 +01:00
})();