Inhibitor

Inhibitors are functions that are designed to prevent or allow a user to run a command. These can range from checking a users specific permission level to checking if the user is on cooldown.
Example

They will always follow this structure.

exports.run = (client, msg, cmd) => { // code here };
exports.conf = {};

Members

static conf :Conf

An object that configures the inhibitor.
Example
exports.conf = {
   enabled: true,
   priority: 0,
   spamProtection: false
 };

Methods

static run(client, msg, cmd) → {string|boolean}

The part of the inhibitor that will determine if the user can use the command or not. This function must return one of three things.
If the user should be allowed to use the command, you will return false.
If the user should prevented from using the command, you will return true. If you do this, the command will be silent.
However, if you would like to give the user a message as to why they couldn't use the command, you can also return a String, such as `return "Not enough permissions to use this command."`.
Parameters:
Name Type Description
client KomadaClient The Komada Client
msg Message A Message object obtained from discord.js
cmd Command The command that the user is trying to run.
Returns:
string | boolean
Example

This will create an inhibitor that only runs when the commands "requiredUser" configuration property has the message authors id in it.

exports.run = (client, msg, cmd) => {
 if (!cmd.conf.requiredUser || !(cmd.conf.requiredUser instanceof Array) || cmd.conf.requiredUser.length === 0) return false;
 if (cmd.conf.requiredUser.includes(message.author.id)) return false;
 return "You are not allowed to use this command.";
}

Type Definitions

Conf

An Object containing configuration values that will configure a inhibitor.
Properties:
Name Type Description
enabled Boolean Whether or not this inhibitor should be enabled for use.
priority Number The priority of this inhibitor. **This will probably be removed in the future**
spamProtection Boolean Whether or not we should run this inhibitor in other places, like the help menu.