Custom commands

This is the cheat sheet for the WildBeast command framework. Using these elements, you can build the command you really want to get into your own instance.

What not to do

Do not come to us with questions on how to write custom commands, some basic JavaScript and programming knowledge is required. We won't give you assistance in writing your commands beyond what is listed on this page!

Intro

Starting at version 3.0.0, WildBeast allows for the addition of user created JavaScript files with commands, given that they are written in the exact same format as default files. This page provides you with the tools you need to create your own commands.

Important notes

  1. Files need to declare commands to an array, and the array needs to be exported as Commands.
    • In practice: var Commands = [] and exports.Commands = Commands
  2. Your command files must be in the custom folder within the commands folder. The path would therefore be ~/WildBeast/runtime/commands/custom.
  3. Commands are objects added to an array.
  4. Aliases can't be shared between commands. This means that a custom command can't have the same alias as a default command. The bot will stop itself from running and spit out an error if this happens, for safety reasons.
  5. Any functions that use for instance config fields and so forth need to be imported in the format ../../file.ext or ../file.ext depending on what folder the file is in.

Property declaration

Command objects consist of different properties which define how the command runs. There are mandatory properties and optional properties, divided into their own lists. The command callback name is decided by the <cmdname> placeholder in Commands.<cmdname>.

Property scheme

Mandatory properties

Property Type Description
name String Command name for the help module, not callback name! See above.
help String Message displayed when help <command> is called on the command.
level String / Number Minimum user access level (0-3 int) required to execute this command. Set to 'master' to restrict usage to config-defined master users.
fn Function Defines the JavaScript function to execute when the command is called.

Optional properties

Property Type Description
noDM Boolean Whether to allow usage in direct messages. Default true.
timeout Number Unsigned integer that defines how long a command will be on timeout before it's usable again. The number represents seconds.
usage String The example of how the command is used when help <command> is called on the command.
overwrite Boolean Whether to accept this command instead of the default one, in case the callback name is the same. Default false.
aliases Array<String> Hardcoded aliases to call this command with in addition to the default callback name.
hidden Boolean Whether to hide the command from the command list returned with help. Default false.

Example structure

Simple command example:

var Commands = [] // Declaration of the command array

Commands.ping = {
  name: 'ping',
  help: 'Check if I still live.'
  timeout: 10,
  overwrite: true, // WildBeast already has a command called ping, will overwrite with this
  aliases: ['pong'],
  level: 0,
  fn: function(msg) {
    msg.channel.sendMessage('I LIVE')
  }
}

exports.Commands = Commands // Expose the commands to the commandcontrol module

Example of command that uses an external module:

var Commands = [] // Declaration of the command array
var config = require('../../../config.json') // Import config

Commands.prefix = {
  name: 'prefix',
  help: 'Ask the bot what the configured prefix is.'
  timeout: 30,
  overwrite: true,
  level: 'master',
  fn: function(msg) {
    msg.channel.sendMessage('My prefix is ' + config.prefix)
  }
}

exports.Commands = Commands // Expose the commands to the commandcontrol module

And that's how easy it is to create your own commands for WildBeast. Good luck in making your commands, and tinker to your heart's desire!