genshin-manager
    Preparing search index...

    Class EnkaManager

    Class for fetching EnkaData from enka.network

    Hierarchy

    Index

    Constructors

    • Create a PromiseEventEmitter.

      Returns EnkaManager

      class MyEmitter extends PromiseEventEmitter<{test: [string]}, 'test'> {}
      const emitter = new MyEmitter()
      emitter.on('test', async (data) => console.log(data))

    Methods

    • Alias for emitter.on(eventName, listener).

      Type Parameters

      • K

      Parameters

      • eventName: "GET_NEW_ENKA_DATA" | GET_NEW_ENKA_DATA | K

        the name of the event.

      • listener: K extends "GET_NEW_ENKA_DATA"
            ? EnkaManagerEventMap[K<K>] extends unknown[]
                ? (...args: EnkaManagerEventMap[K<K>]) => Awaitable
                : never
            : never

        the callback function. (supports async)

      Returns this

      EventEmitter.addListener()

    • Clear cache over nextShowCaseDate

      Returns void

    • Synchronously calls each of the listeners registered for the event namedeventName, in the order they were registered, passing the supplied arguments to each. Returns true if the event had listeners, false otherwise.

      Type Parameters

      • K

      Parameters

      • eventName: "GET_NEW_ENKA_DATA" | GET_NEW_ENKA_DATA | K

        the name of the event.

      • ...args: K extends "GET_NEW_ENKA_DATA" ? EnkaManagerEventMap[K<K>] : never

        arguments to pass to the listeners.

      Returns boolean

      EventEmitter.emit()

    • Fetch All from enka.network

      Parameters

      • uid: number

        UID

      • OptionalfetchOption: RequestInit

        fetch option

      Returns Promise<EnkaData>

      enka data

      The data fetched by this method is stored as a temporary cache. The storage period depends on ttl.

      const enkaManager = new EnkaManager()
      const data = await enkaManager.fetchAll(123456789)
      console.log(data.playerDetail.nickname)
    • Fetch Status from 1 hour ago to now

      Parameters

      • OptionalfetchOption: RequestInit

        fetch option

      Returns Promise<Record<string, APIEnkaStatus>>

      status from 1 hour ago to now

    • Fetch EnkaAccount from enka.network

      Parameters

      • username: string

        enka account username

      • OptionalfetchOption: RequestInit

        fetch option

      Returns Promise<EnkaAccount>

      enka account

      Data fetched by this method is not stored as a temporary cache.

      const enkaManager = new EnkaManager()
      const account = await enkaManager.fetchEnkaAccount('username')
      console.log(account.nickname)
    • Fetch GenshinAccounts from enka.network

      Parameters

      • username: string

        enka account username

      • OptionalfetchOption: RequestInit

        fetch option

      Returns Promise<GenshinAccount[]>

      genshin accounts

      Data fetched by this method is not stored as a temporary cache.

      const enkaManager = new EnkaManager()
      const accounts = await enkaManager.fetchGenshinAccounts('username')
      console.log(accounts[0].uid)
    • Fetch now Status

      Parameters

      • OptionalfetchOption: RequestInit

        fetch option

      Returns Promise<APIEnkaStatus>

      now status

    • Fetch PlayerDetail from enka.network

      Parameters

      • uid: number

        UID

      • OptionalfetchOption: RequestInit

        fetch option

      Returns Promise<PlayerDetail>

      player detail

      The data fetched by this method is stored as a temporary cache. The storage period depends on ttl.

      const enkaManager = new EnkaManager()
      const playerDetail = await enkaManager.fetchPlayerDetail(123456789)
      console.log(playerDetail.nickname)
    • Alias for emitter.removeListener().

      Type Parameters

      • K

      Parameters

      • eventName: "GET_NEW_ENKA_DATA" | GET_NEW_ENKA_DATA | K

        the name of the event.

      • listener: K extends "GET_NEW_ENKA_DATA"
            ? EnkaManagerEventMap[K<K>] extends unknown[]
                ? (...args: EnkaManagerEventMap[K<K>]) => Awaitable
                : never
            : never

        the callback function. (supports async)

      Returns this

      EventEmitter.off()

    • Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventNameand listener will result in the listener being added, and called, multiple times.

      Type Parameters

      • K

      Parameters

      • eventName: "GET_NEW_ENKA_DATA" | GET_NEW_ENKA_DATA | K

        the name of the event.

      • listener: K extends "GET_NEW_ENKA_DATA"
            ? EnkaManagerEventMap[K<K>] extends unknown[]
                ? (...args: EnkaManagerEventMap[K<K>]) => Awaitable
                : never
            : never

        the callback function. (supports async)

      Returns this

      EventEmitter.on()

    • Adds a one-timelistener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

      Type Parameters

      • K

      Parameters

      • eventName: "GET_NEW_ENKA_DATA" | GET_NEW_ENKA_DATA | K

        the name of the event.

      • listener: K extends "GET_NEW_ENKA_DATA"
            ? EnkaManagerEventMap[K<K>] extends unknown[]
                ? (...args: EnkaManagerEventMap[K<K>]) => Awaitable
                : never
            : never

        the callback function. (supports async)

      Returns this

      EventEmitter.once()

    • Removes all listeners, or those of the specified eventName.

      Type Parameters

      • K

      Parameters

      Returns this

      EventEmitter.removeAllListeners()

    • Removes the specified listener from the listener array for the event namedeventName.

      Type Parameters

      • K

      Parameters

      • eventName: "GET_NEW_ENKA_DATA" | GET_NEW_ENKA_DATA | K

        the name of the event.

      • listener: K extends "GET_NEW_ENKA_DATA"
            ? EnkaManagerEventMap[K<K>] extends unknown[]
                ? (...args: EnkaManagerEventMap[K<K>]) => Awaitable
                : never
            : never

        the callback function. (supports async)

      Returns this

      EventEmitter.removeListener()