muse/src/inversify.config.ts

57 lines
2 KiB
TypeScript
Raw Normal View History

2020-03-13 04:41:26 +01:00
import 'reflect-metadata';
import {Container} from 'inversify';
import {TYPES} from './types';
import Bot from './bot';
import {Client} from 'discord.js';
import YouTube from 'youtube.ts';
import Spotify from 'spotify-web-api-node';
import {
DISCORD_TOKEN,
DISCORD_CLIENT_ID,
YOUTUBE_API_KEY,
SPOTIFY_CLIENT_ID,
SPOTIFY_CLIENT_SECRET,
DATA_DIR,
CACHE_DIR
} from './utils/config';
// Services
import Queue from './services/queue';
import Player from './services/player';
// Comands
import Command from './commands';
import Config from './commands/config';
import Play from './commands/play';
import QueueCommad from './commands/queue';
2020-03-14 02:36:42 +01:00
import Seek from './commands/seek';
2020-03-13 04:41:26 +01:00
let container = new Container();
// Bot
container.bind<Bot>(TYPES.Bot).to(Bot).inSingletonScope();
container.bind<Client>(TYPES.Client).toConstantValue(new Client());
// Services
container.bind<Player>(TYPES.Services.Player).to(Player).inSingletonScope();
container.bind<Queue>(TYPES.Services.Queue).to(Queue).inSingletonScope();
// Commands
container.bind<Command>(TYPES.Command).to(Config).inSingletonScope();
container.bind<Command>(TYPES.Command).to(Play).inSingletonScope();
container.bind<Command>(TYPES.Command).to(QueueCommad).inSingletonScope();
2020-03-14 02:36:42 +01:00
container.bind<Command>(TYPES.Command).to(Seek).inSingletonScope();
2020-03-13 04:41:26 +01:00
// Config values
container.bind<string>(TYPES.Config.DISCORD_TOKEN).toConstantValue(DISCORD_TOKEN);
container.bind<string>(TYPES.Config.DISCORD_CLIENT_ID).toConstantValue(DISCORD_CLIENT_ID);
container.bind<string>(TYPES.Config.YOUTUBE_API_KEY).toConstantValue(YOUTUBE_API_KEY);
container.bind<string>(TYPES.Config.DATA_DIR).toConstantValue(DATA_DIR);
container.bind<string>(TYPES.Config.CACHE_DIR).toConstantValue(CACHE_DIR);
// Static libraries
container.bind<YouTube>(TYPES.Lib.YouTube).toConstantValue(new YouTube(YOUTUBE_API_KEY));
container.bind<Spotify>(TYPES.Lib.Spotify).toConstantValue(new Spotify({clientId: SPOTIFY_CLIENT_ID, clientSecret: SPOTIFY_CLIENT_SECRET}));
export default container;