diff options
| author | Stefano <[email protected]> | 2024-11-04 14:51:25 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-11-04 14:51:25 +0100 |
| commit | 250c7d316bd951d279262daa121ce72bf36484b0 (patch) | |
| tree | d673350998a6aa4a1078984cb3c7c62657735189 /src/inversify.config.ts | |
| parent | b2565a3a92f941028284fa014c622213db863bad (diff) | |
| parent | 07bfd32cb33029c0cd8413656c636c56def2f892 (diff) | |
| download | muse-250c7d316bd951d279262daa121ce72bf36484b0.tar.xz muse-250c7d316bd951d279262daa121ce72bf36484b0.zip | |
Merge pull request #1137 from museofficial/develop
Develop
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); |
