fix modules option type definition

This commit is contained in:
hazycora 2023-09-17 01:05:36 -05:00
parent e7ffc2e7ba
commit ad945277e8
No known key found for this signature in database
GPG key ID: 215AF1F81F86940E

View file

@ -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 }> {