src/Core/Validator.js
/**
     * Valid that a command uses the correct format.
     * Will automatically correct the command by using default for some part
     *
     * @static
     * @param {Command} command
     * @returns {Boolean} Whether the command is considered valid or not
     * @memberof Validator
     */
Valid that a command uses the correct format.
Will automatically correct the command by using default for some part

@static
@param {Command} command
@returns {Boolean} Whether the command is considered valid or not
@memberof Validator
Valid that a command uses the correct format . Will automatically correct the command by using default for some part @static @param { Command } command @returns { Boolean } Whether the command is considered valid or not @memberof Validator
static validCommand(command) {
        const PERMS = command.axon.library.enums.PERMISSIONS;
        if (!command.aliases || command.aliases.length === 0) {
            command.aliases = [command.label];
            debug(command.axon, DEBUG_FLAGS.BAD, `[${command.module.label}(${command.fullLabel})] - No aliases... adding default.`);
        } else if (Array.isArray(command.aliases) && !command.aliases.includes(command.fullLabel) ) {
            command.aliases.push(command.label);
            debug(command.axon, DEBUG_FLAGS.BAD, `[${command.module.label}(${command.fullLabel})] - Missing default alias... adding.`);
        } else if (!Array.isArray(command.aliases) && command.aliases !== command.label) {
            command.aliases = [command.aliases, command.label];
            debug(command.axon, DEBUG_FLAGS.BAD, `[${command.module.label}(${command.fullLabel})] - Aliases not an array... fixing.`);
        }
        if (!(command._cooldown instanceof CommandCooldown) ) {
            command._cooldown = new CommandCooldown(command);
            debug(command.axon, DEBUG_FLAGS.BAD, `[${command.module.label}(${command.fullLabel})] - Invalid command cooldown... recreating.`);
        } else {
            debug(command.axon, DEBUG_FLAGS.GOOD, `[${command.module.label}(${command.fullLabel})] - Valid command cooldown.`);
        }
        if (!(command.options instanceof CommandOptions) ) {
            command.options = new CommandOptions(command);
            debug(command.axon, DEBUG_FLAGS.BAD, `[${command.module.label}(${command.fullLabel})] - Invalid command options... using default.`);
        } else {
            debug(command.axon, DEBUG_FLAGS.GOOD, `[${command.module.label}(${command.fullLabel})] - Valid command options.`);
        }
        if (!(command.permissions instanceof CommandPermissions) ) {
            command.permissions = new CommandPermissions(command);
            debug(command.axon, DEBUG_FLAGS.BAD, `[${command.module.label}(${command.fullLabel})] - Invalid command permissions... using default.`);
        } else {
            debug(command.axon, DEBUG_FLAGS.GOOD, `[${command.module.label}(${command.fullLabel})] - Valid command permissions.`);
        }
        for (const perm of command.permissions.bot) {
            if (!this.checkValidPermissionName(PERMS, perm) ) {
                debug(command.axon, DEBUG_FLAGS.BAD, `[${command.module.label}(${command.fullLabel})] - Invalid permissions name (${perm}) in Command.permissions.bot.`);
                return false;
            }
        }
        debug(command.axon, DEBUG_FLAGS.GOOD, `[${command.module.label}(${command.fullLabel})] - Correct permissions name in Command.permissions.bot.`);
        for (const perm of command.permissions.author.needed) {
            if (!this.checkValidPermissionName(PERMS, perm) ) {
                debug(command.axon, DEBUG_FLAGS.BAD, `[${command.module.label}(${command.fullLabel})] - Invalid permissions name (${perm}) in Command.permissions.author.needed.`);
                return false;
            }
        }
        debug(command.axon, DEBUG_FLAGS.GOOD, `[${command.module.label}(${command.fullLabel})] - Correct permissions name in Command.permissions.author.needed.`);
        for (const perm of command.permissions.author.bypass) {
            if (!this.checkValidPermissionName(PERMS, perm) ) {
                debug(command.axon, DEBUG_FLAGS.BAD, `[${command.module.label}(${command.fullLabel})] - Invalid permissions name (${perm}) in Command.permissions.author.bypass.`);
                return false;
            }
        }
        debug(command.axon, DEBUG_FLAGS.GOOD, `[${command.module.label}(${command.fullLabel})] - Correct permissions name in Command.permissions.author.bypass.`);
        return true;
    }
static validCommand ( command ) { const PERMS = command . axon . library . enums . PERMISSIONS ; if ( ! command . aliases || command . aliases . length === 0 ) { command . aliases = [ command . label ] ; debug ( command . axon , DEBUG_FLAGS . BAD , ` ${ command . module . label } ${ command . fullLabel } ` ) ; } else if ( Array . isArray ( command . aliases ) && ! command . aliases . includes ( command . fullLabel ) ) { command . aliases . push ( command . label ) ; debug ( command . axon , DEBUG_FLAGS . BAD , ` ${ command . module . label } ${ command . fullLabel } ` ) ; } else if ( ! Array . isArray ( command . aliases ) && command . aliases !== command . label ) { command . aliases = [ command . aliases , command . label ] ; debug ( command . axon , DEBUG_FLAGS . BAD , ` ${ command . module . label } ${ command . fullLabel } ` ) ; } if ( ! ( command . _cooldown instanceof CommandCooldown ) ) { command . _cooldown = new CommandCooldown ( command ) ; debug ( command . axon , DEBUG_FLAGS . BAD , ` ${ command . module . label } ${ command . fullLabel } ` ) ; } else { debug ( command . axon , DEBUG_FLAGS . GOOD , ` ${ command . module . label } ${ command . fullLabel } ` ) ; } if ( ! ( command . options instanceof CommandOptions ) ) { command . options = new CommandOptions ( command ) ; debug ( command . axon , DEBUG_FLAGS . BAD , ` ${ command . module . label } ${ command . fullLabel } ` ) ; } else { debug ( command . axon , DEBUG_FLAGS . GOOD , ` ${ command . module . label } ${ command . fullLabel } ` ) ; } if ( ! ( command . permissions instanceof CommandPermissions ) ) { command . permissions = new CommandPermissions ( command ) ; debug ( command . axon , DEBUG_FLAGS . BAD , ` ${ command . module . label } ${ command . fullLabel } ` ) ; } else { debug ( command . axon , DEBUG_FLAGS . GOOD , ` ${ command . module . label } ${ command . fullLabel } ` ) ; } for ( const perm of command . permissions . bot ) { if ( ! this . checkValidPermissionName ( PERMS , perm ) ) { debug ( command . axon , DEBUG_FLAGS . BAD , ` ${ command . module . label } ${ command . fullLabel } ${ perm } ` ) ; return false ; } } debug ( command . axon , DEBUG_FLAGS . GOOD , ` ${ command . module . label } ${ command . fullLabel } ` ) ; for ( const perm of command . permissions . author . needed ) { if ( ! this . checkValidPermissionName ( PERMS , perm ) ) { debug ( command . axon , DEBUG_FLAGS . BAD , ` ${ command . module . label } ${ command . fullLabel } ${ perm } ` ) ; return false ; } } debug ( command . axon , DEBUG_FLAGS . GOOD , ` ${ command . module . label } ${ command . fullLabel } ` ) ; for ( const perm of command . permissions . author . bypass ) { if ( ! this . checkValidPermissionName ( PERMS , perm ) ) { debug ( command . axon , DEBUG_FLAGS . BAD , ` ${ command . module . label } ${ command . fullLabel } ${ perm } ` ) ; return false ; } } debug ( command . axon , DEBUG_FLAGS . GOOD , ` ${ command . module . label } ${ command . fullLabel } ` ) ; return true ; }
Valid that a command uses the correct format.
Valid that a command uses the correct format .
/* Correct: No aliases, or aliases does not include the label. */ /* Correct commands properties */ /* Validate Library permissions */