# FAQ

Certain usage albeit the best efforts of maintaining a feature rich documentation isn't always necessarily straight forward. Chariot.js is no exception to this rule, so here are the most frequently asked questions about Chariot.js.

If you have a question not satisfied by this FAQ please feel free to drop by our Discord guild and we'll be sure to help you!

# My bot isn't starting albeit my token being correct!

As of Eris version 0.15.0 and hence Chariot.js version 3.5.0 bot tokens need to be prefixed with Bot to work.

# How do I access the prefix of the command that was run?

Chariot.js simply extends the Message object by a prefix property, which always dynamically corresponds to the prefix that was used to invoke the command. This also applies to custom guild specific prefixes!

Example in a command executor:

/* Main command executor */
async execute(message, args, chariot) {
    message.channel.createMessage(`You used the ${message.prefix} prefix!`);
}

PRO TIP

message.prefix is also available in sub-commands and the runPreconditions method!

# How do I list all prefixes for a specific guild?

As outlined in the Chariot.Client API, the Chariot.js client exposes a property called guildPrefixes which can then be used to filter for guild specific prefixes:

/* Main command executor */
async execute(message, args, chariot) {
    const guildPrefixes = chariot.guildPrefixes.filter((prefixObject) => {
        return prefixObject.guildID === message.channel.guild.id;
    }).map((prefixObject) => {
        return prefixObject.prefix;
    });

    const guildName = message.channel.guild.name;
    const prefixes = (guildPrefixes.length) ? guildPrefixes.join(', ') : 'None';

    message.channel.createMessage(
        `Guild ${guildName} has following custom prefixes: ${prefixes}`
    );
}

# How do I reset a Command's cooldown?

Depending from where a command's cooldown is wished to be reset, either the chariot object given a command or the client class property has to be used to access the main Chariot.js bot client.

/* Inside of a Command file */
chariot.messageHandler.cooldowns.get('commandName').delete('userID');

/* Inside of an Event handler file */
this.client.messageHandler.cooldowns.get('commandName').delete('userID');

With commandName being the command's name set during command instantiation and userID being the user ID Snowflake of the user for who the cooldown should be reset.

PRO TIP

  1. commandName is case sensitive and will cause a failed command cooldown deletion attempt!
  2. userID being a Discord Snowflake requires the provision of the ID as a String and NOT as a Number!

# How do I manually execute a Command?

As documented in the Chariot.Client API reference, commands is an exposed Client property, which is a Collection of all validly registered commands. From there on it's just a matter of obtaining a command and manually invoking the prefered executor!

This automatically also applies for manually executing sub-commands by simply exchanging the execute method with whatever sub-command executor is desired!

/* Inside of a Command file */
chariot.commands.get('commandName').execute(message, args, chariot);

/* Inside of an Event handler file */
this.client.commands.get('commandName').execute(message, args, chariot);

WARNING

Manually invoking commands will completely skip the runPreconditions method of a command if one is present!

HEADS-UP

If a command is manually executed, the provided message property for the executors MUST be a valid Eris.Message object! This especially applies to message partials that can occur on some events, e.g. messageReactionAdd!

# How do I tell Chariot.js to ignore certain folders?

Chariot.js can as of version 3.2.0 ignore folders upon initialization. This means neither command files nor event files will be read from said folders and are fully ignored.

To tell Chariot.js which folders to ignore the corresponding option needs to be set in the Chariot.Config object upon initializing a new Chariot.js client. Head on over to the Chariot.Config API reference for an example configuration to get started quickly.

TIP

Chariot.js only requires folder names, no paths to said folders, even if the folder in question is nested!

# My question is not listed here

If you have a question not satisfied by this FAQ please feel free to drop by our Discord guild and we'll be sure to help you!