commands/help.js
/**
 * @brief This function defines the handler functions for the /ttt help command.
 *
 * @return object 'help' handler object containing the following methods:
 *                - parseArgs
 *                - handle
 */
@brief This function defines the handler functions for the /ttt help command.
@return object 'help' handler object containing the following methods:
- parseArgs
- handle
@brief This function defines the handler functions for the / ttt help command . @return object ' help ' handler object containing the following methods : - parseArgs - handle
function initializeCommand() {
    'use strict';
    const slackUtil = require('../lib/slackutil');
    const constants = require('../lib/constants');
    const config = require('../config');
    const locale = require('../locales').get(config.locale);
    const labels = locale[constants.commands.HELP];
    function parseArgs() {
        return true;
    }
    function handle(req, res) {
        let text = labels.CMD_TEXT;
        let attachment = constants.help.helpUsageSlackAttachment;
        if (req.body.errorMessage !== undefined) {
            text = req.body.errorMessage;
            attachment = constants.help.commandUsageSlackAttachment;
        }
        res.json(
            slackUtil.createResponse({
                text,
                response_type: "ephemeral",
                attachments: [attachment]
            })
        );
    }
    return Object.freeze({
        parseArgs,
        handle
    });
}
function initializeCommand ( ) { 'use strict' ; const slackUtil = require ( '../lib/slackutil' ) ; const constants = require ( '../lib/constants' ) ; const config = require ( '../config' ) ; const locale = require ( '../locales' ) . get ( config . locale ) ; const labels = locale [ constants . commands . HELP ] ; function parseArgs ( ) { return true ; } function handle ( req , res ) { let text = labels . CMD_TEXT ; let attachment = constants . help . helpUsageSlackAttachment ; if ( req . body . errorMessage !== undefined ) { text = req . body . errorMessage ; attachment = constants . help . commandUsageSlackAttachment ; } res . json ( slackUtil . createResponse ( { text , response_type : "ephemeral" , attachments : [ attachment ] } ) ) ; } return Object . freeze ( { parseArgs , handle } ) ; }
@brief This function defines the handler functions for the /ttt help command.
@brief This function defines the handler functions for the / ttt help command .
// Access Slack utility object to format the message response. // Access application constants. // Get current configuration. // Setup locales config /**
     * @brief This function checks the request body to see if all the valid
     *        parameters are present. Since the 'help' command does not need
     *        data, it does not need to validate the request body.
     *
     * @return boolean indicating the request validity
     */ /**
     * @brief This function handles the /ttt 'help' command. It creates a Slack
     *        JSON message explaining the command's usage.
     *
     * @param req express http request object
     * @param res express http response object
     *
     * @return none
     */ // Get help text and attachments. // If an error message is present in req use the appropriate attachment. // Send Slack JSON message as the response.