Bot

new Bot(botOptions: BotOptions, clientOptions?: ClientOptions)

The Discord.js Client instance. Contains bot-specific storage, guild specific storages, and contains important fields for access within commands
Parameters:
Name Type Attributes Description
botOptions
BotOptions
Object containing required bot properties
clientOptions
ClientOptions
<optional>
Discord.js ClientOptions

Extends

Events

command

Emitted whenever a command is successfully called
Parameters:
Name Type Description
name
string
Name of the called command
args
Array<args>
Args passed to the called command
original
string
Original content of the message that called the command
execTime
number
Time command took to execute
message
Message
Message that triggered the command

Properties

.commands: CommandRegistry<string, Command>

Collection containing all loaded commands
Type:
CommandRegistry<string, Command>

.commandsDir: string

Directory to find command class files. Optional if bot is passive. See: Bot#passive
Type:
string

.config: Object

Object containing token and owner ids
Type:
Object
Properties:
Name Type Description
token
string
Discord login token for the bot
owner
Array<string>
Array of owner id strings

.disableBase: Array<string>

Array of base command names to skip when loading commands. Base commands may only be disabled by name, not by alias
Type:
Array<string>

.guildStorages: GuildStorageRegistry<string, GuildStorage>

Collection containing all GuildStorage instances
Type:
GuildStorageRegistry<string, GuildStorage>

.name: string

The name of the Bot
Type:
string

.noCommandErr: string

Whether or not a generic 'command not found' message should be given in DMs to instruct the user to use the `help` command. Set to false to disable this message
Type:
string

.passive: boolean

Whether or not this bot is passive. Passive bots will not register a command dispatcher or a message listener. This allows passive bots to be created that do not respond to any commands but are able to perform actions based on whatever the framework user wants
Type:
boolean

.readyText: string

Text to output when the bot is ready
Type:
string

.selfbot: boolean

Whether or not the bot is a selfbot
Type:
boolean

.statusText: string

Status text for the bot
Type:
string

.storage: LocalStorage

Bot-specific storage
Type:
LocalStorage

.version: string

Bot version, best taken from package.json
Type:
string

Methods

.defaultSettingExists(key: string) → boolean

See if a guild default setting exists
Parameters:
Name Type Description
key
string
The key in storage to check
Returns:
boolean

.getPrefix(guild: Guild) → string|null

Shortcut to return the command prefix for the provided guild
Parameters:
Name Type Description
guild
Guild
|
string
The guild or guild id to get the prefix of
Returns:
string
|
null

.loadCommand(command: string)

Loads/reloads all/specific commands
Parameters:
Name Type Description
command
string
The name of a command to reload, or 'all' to load all commands

.removeDefaultSetting(key: string)Bot

Remove a defaultGuildSettings item. Will not remove from ALL guild settings, but will prevent the item from being added to new guild settings storage upon creation
Parameters:
Name Type Description
key
string
The key to use in settings storage
Returns:
Bot

.setDefaultSetting(key: string, value: string)Bot

Set the value of a default setting key and push it to all guild setting storages. Will not overwrite a setting in guild settings storage if there is already an existing key with the given value
Parameters:
Name Type Description
key
string
The key to use in settings storage
value
string
The value to use in settings storage
Returns:
Bot

.start()Bot

Logs the Bot in and registers some event handlers
Returns:
Bot

.sweepStorages()

Clean out any guild storage/settings that no longer have an associated guild