Class Client<Authorized>

Client for the iFunny API.

Type Parameters

  • Authorized extends boolean = boolean

Hierarchy

Constructors

Properties

#config: ClientConfig

The config for the client

#content: ContentManager

Content manager object

#feeds: FeedManager

Feed manager object

The payload for the client

#user: null | User = null
#users: UserManager

User manager object

#util: Util

Client utility class

DEFAULT_CONFIG: ClientConfig = ...

Default Config for the Client

Accessors

  • get authorization(): string
  • The authorization string used for requests

    Returns string

  • get basic(): string
  • Basic token used by the client.
    If not set in constructor, one was generated

    Returns string

  • set basic(value: string): void
  • Sets the basic token for the Client. Must be a string

    Parameters

    • value: string

    Returns void

  • get bearer(): If<Authorized, string, null>
  • The bearer token for the client

    Returns If<Authorized, string, null>

  • set bearer(value: null | string): void
  • Sets the bearer token for the client. If set to null, the client will not use a bearer token.

    Parameters

    • value: null | string

    Returns void

Methods

  • Calls eval with the client set as the "this" context.

    Returns

    The result of the script

    Parameters

    • script: string

      The script to evaluate

    Returns any

  • Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns Client<Authorized>

  • Calls each of the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Rest ...args: any[]

    Returns boolean

  • Return an array listing the events for which the emitter has registered listeners.

    Returns (string | symbol)[]

  • Return the number of listeners listening to a given event.

    Parameters

    • event: string | symbol

    Returns number

  • Return the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T

    Returns ((...args: any[]) => void)[]

  • Logs in using the stored bearer token.
    Does NOT Generate a new bearer token

    Returns Promise<Client<Authorized>>

  • Logs the Client in an generates a new Bearer token.
    If a bearer token is stored, these are ignored

    Parameters

    • email: string

      The email to log in with

    • password: string

      The password to log in with

    Returns Promise<Client<Authorized>>

  • Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optional fn: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns Client<Authorized>

  • Add a listener for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns Client<Authorized>

  • Add a one-time listener for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns Client<Authorized>

  • Prime the Client's basic token

    Returns

    The Client's basic token

    Returns Promise<string>

  • Primes a basic token without updating the Client config. This takes ~15 seconds

    Returns

    Basic token being primed

    Parameters

    • basic: string

      Basic token to prime

    Returns Promise<string>

  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: string | symbol

    Returns Client<Authorized>

  • Remove the listeners of a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optional fn: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns Client<Authorized>

  • When concatenated with a string, this automatically returns the user's nick instead of the User object.

    Example

    console.log(Hello from ${client}!); // Logs: "Hello from iFunnyChef" or "Hello from Guest Client"

    Returns string

Generated using TypeDoc