Fix Hound Violations
This commit is contained in:
parent
2ec2e81853
commit
de2d589504
2 changed files with 10 additions and 10 deletions
|
@ -10,13 +10,13 @@ class event {
|
||||||
// Get the prefix from the config
|
// Get the prefix from the config
|
||||||
let prefix = this.config.prefix;
|
let prefix = this.config.prefix;
|
||||||
|
|
||||||
// If the message starts with the prefix, then treat it as a command
|
// If the message starts with the prefix, then treat it as a command
|
||||||
if (message.content.substring(0, prefix.length).toLowerCase() == prefix.toLowerCase()) {
|
if (message.content.substring(0, prefix.length).toLowerCase() == prefix.toLowerCase()) {
|
||||||
// Get the arguments in the message, after the first space (after the command name)
|
// Get the arguments in the message, after the first space (after the command name)
|
||||||
let args = message.content.substring(prefix.length).split(" ");
|
let args = message.content.substring(prefix.length).split(" ");
|
||||||
let name = args.shift();
|
let name = args.shift();
|
||||||
|
|
||||||
// Load the command from the util class
|
// Load the command from the util class
|
||||||
this.util.loadCommand(name, args, message);
|
this.util.loadCommand(name, args, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,24 +11,24 @@ class util {
|
||||||
|
|
||||||
// Load a command and send the arguments with it
|
// Load a command and send the arguments with it
|
||||||
loadCommand(name, args, message) {
|
loadCommand(name, args, message) {
|
||||||
// Loop through all folders set in config
|
// Loop through all folders set in config
|
||||||
// c = command folder index
|
// c = command folder index
|
||||||
for (let c = 0; c < this._client.config.commands.length; c++) {
|
for (let c = 0; c < this._client.config.commands.length; c++) {
|
||||||
// Get the current folder to check
|
// Get the current folder to check
|
||||||
let folder = this._client.config.commands[c];
|
let folder = this._client.config.commands[c];
|
||||||
|
|
||||||
// See if the folder being checked has the command being sent
|
// See if the folder being checked has the command being sent
|
||||||
stat(`${process.cwd()}/${folder}/${name}.js`, err => {
|
stat(`${process.cwd()}/${folder}/${name}.js`, err => {
|
||||||
// If no error, attempt to run the command
|
// If no error, attempt to run the command
|
||||||
if (err == null) {
|
if (err == null) {
|
||||||
// Require the command file, now that we know it exists and initialise it
|
// Require the command file, now that we know it exists and initialise it
|
||||||
let commandFile = require(`${process.cwd()}/${folder}/${name}.js`);
|
let commandFile = require(`${process.cwd()}/${folder}/${name}.js`);
|
||||||
let command = new commandFile();
|
let command = new commandFile();
|
||||||
|
|
||||||
// Get the list of required configurations the command needs
|
// Get the list of required configurations the command needs
|
||||||
let requiredConfigs = command.requiredConfigs;
|
let requiredConfigs = command.requiredConfigs;
|
||||||
|
|
||||||
// Loop through all the required configs of the command
|
// Loop through all the required configs of the command
|
||||||
for (let i = 0; i < requiredConfigs.length; i++) {
|
for (let i = 0; i < requiredConfigs.length; i++) {
|
||||||
// If the command doesn't have the configs in the config string, throw an error
|
// If the command doesn't have the configs in the config string, throw an error
|
||||||
if (!this._client.config[name]) throw `${commandFile.name} requires ${requiredConfigs[i]} in it's configuration`;
|
if (!this._client.config[name]) throw `${commandFile.name} requires ${requiredConfigs[i]} in it's configuration`;
|
||||||
|
|
Reference in a new issue