Commands are pieces of code ran when messages contain the bots prefix. Along with these, we have a full argument parsing system for use in commands.
Example
They will always follow this structure
exports.run = async (client, msg, ...args) => { // code here };
exports.help = {};
exports.conf = {};
Members
-
static conf :Conf
-
An object that configures the command.
Example
exports.conf = { enabled: true, runIn: ["text", "dm", "group"], aliases: [], permLevel: 0, botPerms: [], requiredFuncs: [], requiredSettings: [], }; -
static help :Help
-
The help object used throughout komada
Example
exports.help = { name: "ping", description: "Ping/Pong command. I wonder what this does? /sarcasm", usage: "", usageDelim: "", };
Methods
-
static run(client, msg, args) → {Promise}
-
The part of the command that will run. This should always return a Promise to prevent issues in Komada. The easy way to do this is to add the async keyword.
Parameters:
Name Type Description clientKomadaClient The Komada Client msgMessage A Message object obtained from discord.js argsArray An array of arguments passed through by our argument parser. Returns:
PromiseExamples
exports.run = (client, msg) => msg.reply("Hello Komada!");exports.run = async (client, msg) => { const message = await msg.channel.send("Hello!"); return message.edit("Hello from Komada!"); }exports.run = async function run(client, msg) { const message = await msg.channel.send("Hello!"); return message.edit("Hello from Komada!"); }
Type Definitions
-
Conf
-
An Object containing configuration values that will configure a command.
Properties:
Name Type Description enabledBoolean Whether or not this command should be enabled for use. runInArray What type of text channels this command should run in. aliasesArray An array of names that will also trigger this command. permLevelNumber What permission level this command should be limited to. botPermsArray What permissions the bot must have to run this command. requiredFuncsArray What functions are required in the bot to run this command. requiredSettingsArray What settings are required in the default schema to run this command. -
Help
-
An object containing help information that will help identify and use a command.
Properties:
Name Type Description nameString The name of the command descriptionString The description displayed in the help usageString A usage string that denotes how the command should be used. usageDelimString A character(s) to split the message content by and determine arguments.