muse/src/index.ts

24 lines
643 B
TypeScript
Raw Normal View History

2020-03-13 04:41:26 +01:00
import Spotify from 'spotify-web-api-node';
2020-03-17 01:37:54 +01:00
import makeDir from 'make-dir';
import container from './inversify.config';
2020-03-13 04:41:26 +01:00
import {TYPES} from './types';
import Bot from './bot';
2020-03-17 01:37:54 +01:00
import {sequelize} from './utils/db';
2020-03-09 17:57:39 +01:00
2020-03-13 04:41:26 +01:00
let bot = container.get<Bot>(TYPES.Bot);
const spotify = container.get<Spotify>(TYPES.Lib.Spotify);
2020-03-09 17:57:39 +01:00
2020-03-13 04:41:26 +01:00
(async () => {
const auth = await spotify.clientCredentialsGrant();
2020-03-09 17:57:39 +01:00
2020-03-13 04:41:26 +01:00
spotify.setAccessToken(auth.body.access_token);
2020-03-09 17:57:39 +01:00
2020-03-17 01:37:54 +01:00
// Create data directories if necessary
await makeDir(container.get(TYPES.Config.DATA_DIR));
await makeDir(container.get(TYPES.Config.CACHE_DIR));
await sequelize.sync({});
2020-03-13 04:41:26 +01:00
bot.listen();
})();