Home Manual Reference Source Repository
public class | source

Bot

A Discord bot that has its own command registry, storage, utilities, etc.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public
public
public
public
public get
public
public get
public
public

Method Summary

Public Methods
public

Create a command builder

public

Instantiates all bot classes and storages, and creates the client

public

Registers a single command to the bot's registry

public

registerCommands(commands: Command[] | function[]): Bot

Registers multiple commands to the bot's registry

public

Registers the default commands to the bot's registry

public

Registers the default modules to the bot's registry

public

Registers both the default modules and commands to the bot's registry

public

Registers a single object to be usable by the eval command

public

Registers multiple objects to be usable by the eval command

public

Registers a single module to the bot's registry

public

registerModules(modules: Module[] | function[] | Array[]): Bot

Registers multiple modules to the bot's registry

Public Constructors

public constructor(config: ConfigObject) source

Params:

NameTypeAttributeDescription
config ConfigObject

The configuration to use

Public Members

public client: Client source

public config: BotConfig source

public dispatcher: CommandDispatcher source

public evalObjects: Object source

public localStorage: LocalStorage source

public get logger: Logger source

public permissions: BotPermissions source

public get registry: CommandRegistry source

public storage: Object source

Properties:

NameTypeAttributeDescription
settings SettingStorage
modRoles ModRoleStorage
allowedChannels AllowedChannelStorage

public util: BotUtil source

Public Methods

public buildCommand(info: CommandInfo, funcs: CommandBuilderFunctions): CommandBuilder source

Create a command builder

Params:

NameTypeAttributeDescription
info CommandInfo
  • optional

The command information

funcs CommandBuilderFunctions
  • optional

The command functions to set

Return:

CommandBuilder

The builder

public createClient(): Client source

Instantiates all bot classes and storages, and creates the client

Return:

Client

The bot client

public registerCommand(command: Command | function): Bot source

Registers a single command to the bot's registry

Params:

NameTypeAttributeDescription
command Command | function

Either a Command instance, or a constructor for one

Return:

Bot

This bot

See:

public registerCommands(commands: Command[] | function[]): Bot source

Registers multiple commands to the bot's registry

Params:

NameTypeAttributeDescription
commands Command[] | function[]

An array of Command instances or constructors

Return:

Bot

This bot

public registerDefaultCommands(options: Object): Bot source

Registers the default commands to the bot's registry

Params:

NameTypeAttributeDescription
options Object
  • optional

Object specifying what commands to register

options.about boolean
  • optional
  • default: true

Whether or not to register the built-in about command

options.modRoles boolean
  • optional
  • default: true

Whether or not to register the built-in mod roles commands

options.channels boolean
  • optional
  • default: true

Whether or not to register the built-in channels commands

options.blacklist boolean
  • optional
  • default: true

Whether or not to register the built-in blacklist commands

Return:

Bot

This bot

public registerDefaultModules(): Bot source

Registers the default modules to the bot's registry

Return:

Bot

This bot

public registerDefaults(): Bot source

Registers both the default modules and commands to the bot's registry

Return:

Bot

This bot

public registerEvalObject(key: string, obj: Object): Bot source

Registers a single object to be usable by the eval command

Params:

NameTypeAttributeDescription
key string

The key for the object

obj Object

The object

Return:

Bot

This bot

See:

public registerEvalObjects(obj: Object): Bot source

Registers multiple objects to be usable by the eval command

Params:

NameTypeAttributeDescription
obj Object

An object of keys: values

Return:

Bot

This bot

public registerModule(module: Module | function | string[]): Bot source

Registers a single module to the bot's registry

Params:

NameTypeAttributeDescription
module Module | function | string[]

A Module instance, a constructor, or an array of [ID, Name]

Return:

Bot

This bot

See:

public registerModules(modules: Module[] | function[] | Array[]): Bot source

Registers multiple modules to the bot's registry

Params:

NameTypeAttributeDescription
modules Module[] | function[] | Array[]

An array of Module instances, constructors, or arrays of [ID, Name]

Return:

Bot

This bot