Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Client

The Klasa-Core Client used to wrap the discord api

Hierarchy

Index

Constructors

constructor

Properties

Readonly actions

actions: ActionStore

The action store.

api

api: REST

The rest api interface

Readonly channels

channels: ChannelStore

The channels that have been cached, mapped by their {@link Channel#id IDs}.

Readonly dms

The DM channels that have been cached, mapped by their {@link Channel#id IDs}.

Readonly events

events: EventStore

The event store.

Readonly guilds

guilds: GuildStore

The collection of guilds the client is currently handling, mapped by their {@link Guild#id IDs}

Readonly invites

invites: InviteStore

The invites that have been cached, mapped by their codes.

options

options: DeepRequired<ClientOptions>

The options to use for this client

Readonly pieceStores

pieceStores: Cache<string, Store<Piece>>

The Store registry.

Private pluginLoadedCount

pluginLoadedCount: number = 0

The number of plugins loaded.

user

user: ClientUser | null

The client user

userBaseDirectory

userBaseDirectory: string = dirname((require.main as NodeJS.Module).filename)

The directory where the user files are at.

Readonly users

users: UserStore

The users that have been cached, mapped by their {@link User#id IDs}.

ws

ws: WebSocketManager

The WebSocket manager

Static Readonly plugin

plugin: keyof symbol = Symbol('KlasaCorePlugin')

The plugin symbol to be used in external packages

Static Private Readonly plugins

plugins: Set<(this: Client) => void> = new Set<(this: Client) => void>()

The plugins to be used when creating a Client instance

Accessors

emojis

token

  • set token(token: string): void

Methods

Protected _sweepMessages

  • _sweepMessages(lifetime?: number): number
  • Sweeps all text-based channels' messages and removes the ones older than the max message or command message lifetime. If the message has been edited, the time of the edit is used rather than the time of the original message.

    since

    0.5.0

    Parameters

    • Default value lifetime: number = this.options.cache.messageLifetime

      Messages that are older than this (in milliseconds) will be removed from the caches. The default is based on {@link ClientOptions#messageLifetime}

    Returns number

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

connect

  • connect(): Promise<void>

destroy

  • destroy(): Promise<void>

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getMaxListeners

  • getMaxListeners(): number

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

Protected loadPlugins

  • loadPlugins(): void

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

registerStore

  • registerStore<V>(store: Store<V>): this
  • Registers a custom store to the client

    since

    0.0.1

    chainable

    Type parameters

    Parameters

    • store: Store<V>

      The store that pieces will be stored in

    Returns this

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

unregisterStore

  • unregisterStore<V>(store: Store<V>): this
  • Un-registers a custom store from the client

    since

    0.0.1

    chainable

    Type parameters

    Parameters

    • store: Store<V>

      The store that pieces will be stored in

    Returns this

Static use

Generated using TypeDoc