new KlasaClient(config)
Constructs the klasa client
Parameters:
| Name | Type | Description |
|---|---|---|
config |
KlasaClientConfig | The config to pass to the new client |
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L77
- Tutorials:
Extends
Properties
-
<static> defaultPermissionLevels :PermissionLevels
-
The default PermissionLevels
Type:
- Since:
-
- 0.2.1
- Source:
- lib/Client.js#L435
-
application :external:ClientApplication
-
The application info cached from the discord api
Type:
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L261
-
argResolver :ArgResolver
-
The argument resolver
Type:
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L125
-
clientBaseDir :string
-
The directory where the user files are at
Type:
- string
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L105
-
commandMessageLifetime :number
-
The threshold for how old command messages can be before sweeping since the last edit in seconds
Type:
- number
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L209
-
commandMessages :external:Collection
-
The cache of command messages and responses to be used for command editing
Type:
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L195
-
commandMessageSweep :number
-
The interval duration for which command messages should be sweept in seconds
Type:
- number
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L216
-
commands :CommandStore
-
The cache where commands are stored
Type:
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L132
-
config :KlasaClientConfig
-
The config passed to the new Klasa.Client
Type:
- KlasaClientConfig
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L86
-
console :KlasaConsole
-
The console for this instance of klasa. You can disable timestmaps, colors, and add writable streams as config options to configure this.
Type:
- Since:
-
- 0.4.0
- Source:
- lib/Client.js#L112
-
coreBaseDir :string
-
The directory to the node_modules folder where Klasa exists
Type:
- string
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L98
-
events :EventStore
-
The cache where events are stored
Type:
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L174
-
extendables :ExtendableStore
-
The cache where extendables are stored
Type:
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L181
-
finalizers :FinalizerStore
-
The cache where finalizers are stored
Type:
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L146
-
inhibitors :InhibitorStore
-
The cache where inhibitors are stored
Type:
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L139
-
<readonly> invite
-
The invite link for the bot
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L282
-
languages :LanguageStore
-
The cache where languages are stored
Type:
- Since:
-
- 0.2.1
- Source:
- lib/Client.js#L160
-
methods :object
-
Additional methods to be used elsewhere in the bot
Type:
- object
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L238
Properties:
Name Type Description Collectionclass A discord.js collection Embedclass A discord.js Message Embed MessageCollectorclass A discord.js MessageCollector Webhookclass A discord.js WebhookClient escapeMarkdownfunction A discord.js escape markdown function splitMessagefunction A discord.js split message function CommandMessageclass A command message utilUtil A collection of static methods to be used thoughout the bot -
monitors :MonitorStore
-
The cache where monitors are stored
Type:
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L153
-
<readonly> owner :external:User
-
The owner for this bot
Type:
- Since:
-
- 0.1.1
- Source:
- lib/Client.js#L377
-
permissionLevels :PermissionLevels
-
The permissions structure for this bot
Type:
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L202
-
pieceStores :external:Collection
-
A Store registry
Type:
- Since:
-
- 0.3.0
- Source:
- lib/Client.js#L188
-
providers :ProviderStore
-
The cache where providers are stored
Type:
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L167
-
ready :boolean
-
Whether the client is truely ready or not
Type:
- boolean
- Since:
-
- 0.0.1
- Source:
- lib/Client.js#L223
-
settings :Object
-
The object where the gateways are stored settings
Type:
- Object
- Since:
-
- 0.3.0
- Source:
- lib/Client.js#L254
Methods
-
<async> login(token)
-
Use this to login to Discord with your bot
Parameters:
Name Type Description tokenstring Your bot token - Since:
-
- 0.0.1
- Source:
- lib/Client.js#L358
Returns:
- Type
- Promise.<string>
-
registerPiece(pieceName, store)
-
Registers a custom piece to the client
Parameters:
Name Type Description pieceNamestring The name of the piece, if you want to register an arg resolver for this piece storeStore The store that pieces will be stored in. - Since:
-
- 0.3.0
- Source:
- lib/Client.js#L330
Returns:
this client- Type
- KlasaClient
-
registerStore(store)
-
Registers a custom store to the client
Parameters:
Name Type Description storeStore The store that pieces will be stored in. - Since:
-
- 0.3.0
- Source:
- lib/Client.js#L307
Returns:
this client- Type
- KlasaClient
-
sweepCommandMessages(lifetime)
-
Sweeps command messages based on the lifetime parameter
Parameters:
Name Type Description lifetimenumber The threshold for how old command messages can be before sweeping since the last edit in seconds - Since:
-
- 0.0.1
- Source:
- lib/Client.js#L409
Returns:
The amount of messages swept- Type
- number
-
unregisterPiece(pieceName)
-
Unregisters a custom piece from the client
Parameters:
Name Type Description pieceNamestring The name of the piece - Since:
-
- 0.3.0
- Source:
- lib/Client.js#L347
Returns:
this client- Type
- KlasaClient
-
unregisterStore(storeName)
-
Unregisters a custom store from the client
Parameters:
Name Type Description storeNameStore The store that pieces will be stored in. - Since:
-
- 0.3.0
- Source:
- lib/Client.js#L318
Returns:
this client- Type
- KlasaClient
Type Definitions
-
KlasaClientConfig
-
Type:
- Object
- Source:
- lib/Client.js#L26
Properties:
Name Type Argument Default Description prefixstring The default prefix the bot should respond to clientOptionsDiscordJSConfig <optional>
{} The options to pass to D.JS permissionLevelsPermissionLevels <optional>
KlasaClient.defaultPermissionLevels The permission levels to use with this bot clientBaseDirstring <optional>
path.dirname(require.main.filename) The directory where all piece folders can be found commandMessageLifetimenumber <optional>
1800 The threshold for how old command messages can be before sweeping since the last edit in seconds commandMessageSweepnumber <optional>
900 The interval duration for which command messages should be sweept in seconds providerobject <optional>
The provider to use in Klasa consoleKlasaConsoleConfig <optional>
{} Config options to pass to the client console consoleEventsKlasaConsoleEvents <optional>
{} Config options to pass to the client console languagestring <optional>
'en-US' The default language Klasa should opt-in for the commands promptTimenumber <optional>
30000 The amount of time in milliseconds prompts should last ignoreBotsboolean <optional>
true Whether or not this bot should ignore other bots ignoreSelfboolean <optional>
true Whether or not this bot should ignore itself cmdPromptboolean <optional>
false Whether the bot should prompt missing parameters cmdEditingboolean <optional>
false Whether the bot should update responses if the command is edited cmdLoggingboolean <optional>
false Whether the bot should log command usage typingboolean <optional>
false Whether the bot should type while processing commands. quotedStringSupportboolean <optional>
false Whether the bot should default to using quoted string support in arg parsing, or not (overridable per command) readyMessagestring | function <optional>
<nullable>
`Successfully initialized. Ready to serve ${this.guilds.size} guilds.` readyMessage to be passed thru Klasa's ready event ownerIDstring <optional>
The discord user id for the user the bot should respect as the owner (gotten from Discord api if not provided) -
KlasaConsoleConfig
-
Type:
- Object
- Source:
- lib/Client.js#L51
Properties:
Name Type Argument Default Description stdoutWriteableStream <optional>
process.stdout Output stream stderrWriteableStream <optional>
process.stderr Error stream useColorboolean <optional>
false Whether the client console should use colors colorsColors <optional>
Color formats to use timestampsboolean | string <optional>
true Whether to use timestamps or not, or the moment format of the timestamp you want to use -
KlasaConsoleEvents
-
Type:
- Object
- Source:
- lib/Client.js#L61
Properties:
Name Type Argument Default Description logboolean <optional>
true If the log event should be enabled by default warnboolean <optional>
true If the warn event should be enabled by default errorboolean <optional>
true If the error event should be enabled by default debugboolean <optional>
false If the debug event should be enabled by default verboseboolean <optional>
false If the verbose event should be enabled by default wtfboolean <optional>
true If the wtf event should be enabled by default
Events
-
commandError
-
Emitted when a command has errored.
Parameters:
Name Type Description messageCommandMessageProxy The message that triggered the command commandCommand The command run paramsArray.<any> The resolved parameters of the command errorstring | Object The command error - Since:
-
- 0.3.0
- Source:
- lib/Client.js#L498
-
commandInhibited
-
Emitted when a command has been inhibited.
Parameters:
Name Type Argument Description messageexternal:Message The message that triggered the command commandCommand The command triggered responsestring <nullable>
The reason why it was inhibited if not silent - Since:
-
- 0.3.0
- Source:
- lib/Client.js#L479
-
commandRun
-
Emitted when a command has been run.
Parameters:
Name Type Argument Description messageCommandMessageProxy The message that triggered the command commandCommand The command run paramsArray.<any> The resolved parameters of the command responseany <nullable>
Usually a response message, but whatever the command returned. - Since:
-
- 0.3.0
- Source:
- lib/Client.js#L488
-
commandUnknown
-
Emitted when an unknown command is called.
Parameters:
Name Type Description messageexternal:Message The message that triggered the command commandstring The command attempted to run - Since:
-
- 0.4.0
- Source:
- lib/Client.js#L471
-
klasaReady
-
Emitted when klasa is fully ready and initialized.
- Since:
-
- 0.3.0
- Source:
- lib/Client.js#L443
-
log
-
A central logging event for klasa.
Parameters:
Name Type Argument Default Description datastring | Object The data to log typestring <optional>
'log' The type of log: 'log', 'debug', 'warn', or 'error'. - Since:
-
- 0.3.0
- Source:
- lib/Client.js#L449
-
pieceDisabled
-
Emitted when a piece is disabled.
Parameters:
Name Type Description piecePiece The piece that was disabled - Since:
-
- 0.4.0
- Source:
- lib/Client.js#L546
-
pieceEnabled
-
Emitted when a piece is enabled.
Parameters:
Name Type Description piecePiece The piece that was enabled - Since:
-
- 0.4.0
- Source:
- lib/Client.js#L539
-
pieceLoaded
-
Emitted when a piece is loaded. (This can be spammy on bot startup or anytime you reload all of a piece type.)
Parameters:
Name Type Description piecePiece The piece that was loaded - Since:
-
- 0.4.0
- Source:
- lib/Client.js#L518
-
pieceReloaded
-
Emitted when a piece is reloaded.
Parameters:
Name Type Description piecePiece The piece that was reloaded - Since:
-
- 0.4.0
- Source:
- lib/Client.js#L532
-
pieceUnloaded
-
Emitted when a piece is unloaded.
Parameters:
Name Type Description piecePiece The piece that was unloaded - Since:
-
- 0.4.0
- Source:
- lib/Client.js#L525
-
settingUpdate
-
Emitted when
SettingGateway.update,SettingGateway.updateArrayorSettingGateway.resetis run.Parameters:
Name Type Description gatewaySettingGateway The setting gateway with the updated setting idstring The identifier of the gateway that was updated oldEntriesObject The old settings entries newEntriesObject The new settings entries - Since:
-
- 0.3.0
- Source:
- lib/Client.js#L508
-
verbose
-
An event for handling verbose logs
Parameters:
Name Type Description datastring | Object The data to log - Since:
-
- 0.4.0
- Source:
- lib/Client.js#L457
-
wtf
-
An event for handling wtf logs (what a terrible failure)
Parameters:
Name Type Description datastring | Object The data to log - Since:
-
- 0.4.0
- Source:
- lib/Client.js#L464