Skip to content
This repository has been archived by the owner on Jul 8, 2019. It is now read-only.

Commands

Nitrous edited this page Jan 28, 2018 · 14 revisions

To create a new command, make a new JavaScript file under commands directory with the file name being the command's name. To create a new subgroup, make a new directory with the directory's name being the subgroup's name and json file with the subgroup folder's name for metadata. Files and directory names should never have a whitespace while file names should never have the same name as their subdirectory name to avoid confusion.

Command Tree Structure

The commands are structured as is:

commands
 L example.js
 L subgroup
   L subgroup.json
   L subgroupedcommand.js
  • You can run a command from the root with example
  • You can run a command from a subgroup with subgroup subgroupedcommand

Example Command

From example.js

module.exports = {
    name: 'Example',
    desc: 'Example Command',
    help: 'Example Command',
    args: [''],
    preq: [''],
    perm: [''],
    run: (bot, msg, args) => {
        msg.channel.send('Hello World!');
    }
}

Command Properties

Key Value Type Value Description
name String Name to be displayed.
desc String Description to be displayed.
help String Full help text to be displayed in "help" command.
args String Array Arguments to be displayed.
preq String Array Prerequisites required to run command.
perm String Array Permissions required to run command.
run Function The command's run action.

Run Action

The run action receives 3 arguments:

  • bot - The bot instance being run
  • msg - The Message Object
  • args - The arguments in String Array being passed down from a command

Example Subgroup JSON

{
    "name": "Example Subgroup",
    "desc": "Meaningful description",
    "preq": [],
    "perm": [],
}

Subgroup JSON Properties

Key Value Type Value Description
name String Name to be displayed.
desc String Description text to be displayed.
preq String Parent Prerequisites to inherit to children.
perm String Parent Permissions to inherit to children.

Permissions

All permissions are based off on discord.js Permission Flags.

Clone this wiki locally