diff options
| author | Bobby <[email protected]> | 2024-11-06 09:42:25 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-11-06 09:42:25 -0500 |
| commit | d92fd2a29796c9c5d6ddeb9718bf6fcd6ee5958a (patch) | |
| tree | 81961cc995661448794669617f1ed439cbe84a3d /src/inversify.config.ts | |
| parent | b605bf220859acd767533e0ab9436ced771bb8e2 (diff) | |
| parent | 716d6d9f4f2cd1a6872e463e9877203a259478a3 (diff) | |
| download | muse-d92fd2a29796c9c5d6ddeb9718bf6fcd6ee5958a.tar.xz muse-d92fd2a29796c9c5d6ddeb9718bf6fcd6ee5958a.zip | |
Diffstat (limited to 'src/inversify.config.ts')
| -rw-r--r-- | src/inversify.config.ts | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/inversify.config.ts b/src/inversify.config.ts index 2f2005e..8e621cb 100644 --- a/src/inversify.config.ts +++ b/src/inversify.config.ts @@ -57,11 +57,20 @@ container.bind<Client>(TYPES.Client).toConstantValue(new Client({intents})); // Managers container.bind<PlayerManager>(TYPES.Managers.Player).to(PlayerManager).inSingletonScope(); +// Config values +container.bind(TYPES.Config).toConstantValue(new ConfigProvider()); + // Services container.bind<GetSongs>(TYPES.Services.GetSongs).to(GetSongs).inSingletonScope(); container.bind<AddQueryToQueue>(TYPES.Services.AddQueryToQueue).to(AddQueryToQueue).inSingletonScope(); container.bind<YoutubeAPI>(TYPES.Services.YoutubeAPI).to(YoutubeAPI).inSingletonScope(); -container.bind<SpotifyAPI>(TYPES.Services.SpotifyAPI).to(SpotifyAPI).inSingletonScope(); + +// Only instanciate spotify dependencies if the Spotify client ID and secret are set +const config = container.get<ConfigProvider>(TYPES.Config); +if (config.SPOTIFY_CLIENT_ID !== '' && config.SPOTIFY_CLIENT_SECRET !== '') { + container.bind<SpotifyAPI>(TYPES.Services.SpotifyAPI).to(SpotifyAPI).inSingletonScope(); + container.bind(TYPES.ThirdParty).to(ThirdParty); +} // Commands [ @@ -91,12 +100,7 @@ container.bind<SpotifyAPI>(TYPES.Services.SpotifyAPI).to(SpotifyAPI).inSingleton container.bind<Command>(TYPES.Command).to(command).inSingletonScope(); }); -// Config values -container.bind(TYPES.Config).toConstantValue(new ConfigProvider()); - // Static libraries -container.bind(TYPES.ThirdParty).to(ThirdParty); - container.bind(TYPES.FileCache).to(FileCacheProvider); container.bind(TYPES.KeyValueCache).to(KeyValueCacheProvider); |
