If you utilize the internal state for the bot, you can define the type and pass a generic type on initialization of the bot. Example:
interface BotState { ... }
const botWithState = new Bot<BotState>({ prefix: ';;' })
const botWithoutState = new Bot({ prefix: ';;' })
Creates new bot instance.
Discord client to listen to messages on.
The commands that are defined on the bot. Not suggested to edit directly.
Generic error given to user if an unexpected error occurs during command operation
Error given to user when they try an unregistered command.
The prefix that marks a command for this bot. For example, prefix: "!"
would mean that the bot would consider any message that starts with !
to be intended for it.
The current state of the bot. Do not edit this directly.
Set of functions that will be called when the state is changed.
Stop listening on current client and destroy it.
The bot instance.
Dispatches state update event.
The previous state of the bot before the update.
The current, updated state of the bot.
Listen to messages on this client.
The Discord client to listen on.
The bot instance.
Called when an unexpected error occurs when running a command. Replies with Bot.errorMessage.
Error received. Printed to the console.
Request received.
Called when the bot either receives the general help
command or the command-level help command (<prefix><command> --help
).
Responds with the defined help message.
Request received.
Called when a user attempts to run an unregistered command. Replies with Bot.invalidCommandError.
The message received.
Set a listener to trigger when the state updates.
This bot instance.
Parse message if it starts with the bot prefix.
The message contents, split by spaces and with the prefix removed.
Called when a message is received. Interprets if it's intended for the bot and then calls the intended command (if registered).
The received message.
Returns Promise<false>
if the message is clearly not intended for the bot.
Register a command all in one place. Note: subcommands can only be defined after their parent commands are registered.
Command definition.
The bot instance.
Register a command. Note: subcommands can only be defined after their parent commands are registered.
What needs to be called to trigger a command. Example: echo
or roll advantage
.
What to do when the command is called.
The bot instance.
Register a command with a help message. Note: subcommands can only be defined after their parent commands are registered.
What needs to be called to trigger a command. Example: echo
or roll advantage
.
What to do when the command is called.
The help message.
The bot instance.
Updates state of the bot. Triggers a state update event. See Bot.onStateUpdate.
Either whole or partial state to merge into the current state.
This bot instance.
Find the command at this exact command path. Throws an error if not found.
The command path to search for a command at.
The command found at the command path.
Try and find a command that matches a list of arguments. Dives deeper until it cannot recognize a registered command.
The arguments which might contain a command path.
The command (or not) and the path taken to get there.
Generated using TypeDoc
The main bot framework.