mirror of
https://codeberg.org/lucida/lucida.git
synced 2026-11-14 15:47:27 -05:00
fix modules option type definition
This commit is contained in:
11
src/index.ts
11
src/index.ts
@@ -1,7 +1,7 @@
|
|||||||
import { GetByUrlResponse, SearchResults, StreamerWithLogin } from './types.js'
|
import { GetByUrlResponse, SearchResults, Streamer, StreamerWithLogin } from './types.js'
|
||||||
|
|
||||||
interface LucidaOptions {
|
interface LucidaOptions {
|
||||||
modules: { [key: string]: StreamerWithLogin }
|
modules: { [key: string]: Streamer | StreamerWithLogin }
|
||||||
logins?: {
|
logins?: {
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
username: string
|
username: string
|
||||||
@@ -11,7 +11,7 @@ interface LucidaOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Lucida {
|
class Lucida {
|
||||||
modules: { [key: string]: StreamerWithLogin }
|
modules: { [key: string]: Streamer | StreamerWithLogin }
|
||||||
hostnames: string[]
|
hostnames: string[]
|
||||||
logins?: { [key: string]: { username: string; password: string } }
|
logins?: { [key: string]: { username: string; password: string } }
|
||||||
constructor(options: LucidaOptions) {
|
constructor(options: LucidaOptions) {
|
||||||
@@ -25,7 +25,10 @@ class Lucida {
|
|||||||
if (!this.logins) throw new Error('No logins specified')
|
if (!this.logins) throw new Error('No logins specified')
|
||||||
for (const i in this.logins) {
|
for (const i in this.logins) {
|
||||||
const credentials = this.logins[i]
|
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 }> {
|
async search(query: string, limit: number): Promise<{ [key: string]: SearchResults }> {
|
||||||
|
|||||||
Reference in New Issue
Block a user