Options
All
  • Public
  • Public/Protected
  • All
Menu

Class KlasaClient

The client for handling everything. See {@tutorial GettingStarted} for more information how to get started using this class.

tutorial

GettingStarted

Hierarchy

Index

Constructors

constructor

Properties

Readonly actions

actions: ActionStore

The action store.

api

api: REST

The rest api interface

application

application: Application | null

The application info cached from the discord api

since

0.0.1

arguments

arguments: ArgumentStore

The cache where argument resolvers are stored

since

0.5.0

Readonly channels

channels: ChannelStore

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

commands

commands: CommandStore

The cache where commands are stored

since

0.0.1

console

console: KlasaConsole

The console for this instance of klasa. You can disable timestamps, colors, and add writable streams as configuration options to configure this.

since

0.4.0

Readonly dms

dms: DMChannelStore

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

Readonly events

events: EventStore

The event store.

extendables

extendables: ExtendableStore

The cache where extendables are stored

since

0.0.1

finalizers

finalizers: FinalizerStore

The cache where finalizers are stored

since

0.0.1

gateways

gateways: GatewayStore

The GatewayStore instance where the gateways are stored

since

0.5.0

Readonly guilds

guilds: GuildStore

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

inhibitors

inhibitors: InhibitorStore

The cache where inhibitors are stored

since

0.0.1

Readonly invites

invites: InviteStore

The {@link Invite invites} that have been cached, mapped by their codes.

languages

languages: LanguageStore

The cache where languages are stored

since

0.2.1

mentionPrefix

mentionPrefix: RegExp | null

The regexp for a prefix mention

since

0.5.0

monitors

monitors: MonitorStore

The cache where monitors are stored

since

0.0.1

options

options: DeepRequired<ClientOptions>

The options to use for this client

owners

owners: Set<User>

The owners for this bot

since

0.5.0

permissionLevels

permissionLevels: PermissionLevels

The permissions structure for this bot

since

0.0.1

Readonly pieceStores

pieceStores: Cache<string, Store<Piece>>

The Store registry.

providers

providers: ProviderStore

The cache where providers are stored

since

0.0.1

ready

ready: boolean

schedule

schedule: Schedule

The Schedule that runs the tasks

since

0.5.0

serializers

serializers: SerializerStore

The Serializers where serializers are stored

since

0.5.0

settings

settings: Settings | null

The Settings instance that handles this client's settings

since

0.5.0

tasks

tasks: TaskStore

The cache where tasks are stored

since

0.5.0

user

user: ClientUser | null

The client user

userBaseDirectory

userBaseDirectory: string

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 basePermissions

basePermissions: Permissions = new Permissions(3072)

The base Permissions that the {@link Client#invite} asks for. Defaults to [VIEW_CHANNEL, SEND_MESSAGES]

since

0.5.0

Static defaultClientSchema

defaultClientSchema: Schema = new Schema().add('schedules', 'any', { array: true })

The default Client Schema

since

0.5.0

Static defaultGuildSchema

defaultGuildSchema: Schema = new Schema().add('prefix', 'string').add('language', 'language').add('disabledCommands', 'command', {array: true,filter: (_client, command: Command, { language }) => {if (command.guarded) throw language.get('COMMAND_CONF_GUARDED', command.name);}})

The default Guild Schema

since

0.5.0

Static defaultPermissionLevels

defaultPermissionLevels: PermissionLevels = new PermissionLevels().add(0, () => true).add(6, ({ member }) => member && member.permissions.has(Permissions.FLAGS[PermissionsFlags.ManageGuild]), { fetch: true }).add(7, ({ member }) => member && member.id === member.guild.ownerID, { fetch: true }).add(9, ({ author, client }) => client.owners.has(author), { break: true }).add(10, ({ author, client }) => client.owners.has(author))

The default PermissionLevels

since

0.2.1

Static defaultUserSchema

defaultUserSchema: Schema = new Schema()

The default User Schema

since

0.5.0

Static Readonly plugin

plugin: keyof symbol

The plugin symbol to be used in external packages

Accessors

emojis

  • get emojis(): Cache<string, GuildEmoji>
  • Returns a new Cache of all guild emojis.

    since

    0.0.1

    Returns Cache<string, GuildEmoji>

invite

  • get invite(): string | null

token

  • set token(token: string): any
  • Sets the token to use for the api.

    since

    0.0.1

    Parameters

    • token: string

    Returns any

Methods

Protected _sweepMessages

  • _sweepMessages(lifetime?: number, commandLifetime?: 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}

    • Default value commandLifetime: number = this.options.commands.messageLifetime

      Messages that are older than this (in milliseconds) will be removed from the caches. The default is based on {@link CommandHandlingOptions#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>
  • Connects websocket to the api.

    Returns Promise<void>

destroy

  • destroy(): Promise<void>
  • Destroys all timers and disconnects all shards from the websocket

    Returns 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>

fetchApplication

  • fetchApplication(): Promise<Application>

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
  • Loads all plugins to your Client/Extended Client

    Returns 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

    • V: Piece

    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

unregisterStore

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

    since

    0.0.1

    chainable

    Type parameters

    • V: Piece

    Parameters

    • store: Store<V>

      The store that pieces will be stored in

    Returns this

Static use

  • use(mod: typeof Plugin): typeof Client
  • Caches a plugin module to be used when creating a Client instance

    Parameters

    • mod: typeof Plugin

      The module of the plugin to use

    Returns typeof Client

Generated using TypeDoc