From ad945277e849dc12ae703a2425b112b59a85b5f4 Mon Sep 17 00:00:00 2001 From: hazycora Date: Sun, 17 Sep 2023 01:05:36 -0500 Subject: [PATCH] fix modules option type definition --- src/index.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index c814dd1..054939e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ -import { GetByUrlResponse, SearchResults, StreamerWithLogin } from './types.js' +import { GetByUrlResponse, SearchResults, Streamer, StreamerWithLogin } from './types.js' interface LucidaOptions { - modules: { [key: string]: StreamerWithLogin } + modules: { [key: string]: Streamer | StreamerWithLogin } logins?: { [key: string]: { username: string @@ -11,7 +11,7 @@ interface LucidaOptions { } class Lucida { - modules: { [key: string]: StreamerWithLogin } + modules: { [key: string]: Streamer | StreamerWithLogin } hostnames: string[] logins?: { [key: string]: { username: string; password: string } } constructor(options: LucidaOptions) { @@ -25,7 +25,10 @@ class Lucida { if (!this.logins) throw new Error('No logins specified') for (const i in this.logins) { const credentials = this.logins[i] - await this.modules[i]?.login?.(credentials.username, credentials.password) + const module = this.modules[i] + if ('login' in module) { + await module.login?.(credentials.username, credentials.password) + } } } async search(query: string, limit: number): Promise<{ [key: string]: SearchResults }> {