All files apology.js

100% Statements 6/6
100% Branches 0/0
100% Functions 2/2
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53          1x                                             1x                         1x 1x           1x 1x      
/**
 * Ask butlerbot to send an apology on your behalf.
 * @module apology
 * @return {string} - apology message (as a message to discord text channel)
 */
module.exports = {
	name: 'apology',
    description: 'Have butlerbot apologize on your behalf, and take ownership of the mistake.',
    aliases: ['sorry', 'apologize', "apologise", "mybad"],
    usage: '@recipient',
    args: true,
    /**
     * @method execute
     * @param {string} message - command, used to determine which channel to return results
     * @param {string} args - recipient of apology message sent to channel; required
     * @return {string} selected apology with correct formatting and recipient
     */  
    execute(message,args) {   
        /** 
         * @function getApology
         * @return {Object} apology
         * @summary selection of random apology from list
         */    
        function pickApology () {
            /** 
             * @var {string[]} apologyMessages  
             * @summary list of pre-generated apology messages
             */
            let apologyMessages = [
                "my deepest apologies. This is a mistake I will not make again and I volunteer a paycheck reduction.",
                "I owe you an apology. It was never my intention to cause you distress. " + 
                "I wish I’d thought of your feelings as well. But, it is never too late to make things right.",
                "I’m not perfect, I make mistakes, I hurt people. But when I say sorry, I mean it.",
                "I am sorry. I don't know what I was thinking. Obviously I wasn't thinking.",
                "I apologize -- I wouldn't blame you if you don't forgive me. I've messed up big time. I shall commence the self-flagellation at dawn.",
                "I take full responsibility for my action. I know that I could have done things differently, but I made a poor decision that I regret now. " +
                "Please forgive me for my lack of wisdom in the situation. I will revoke all evening tea for the evening for myself.",
                "I am very sorry for what happened. It was unacceptable and will never happen again, unless of course I am asked to.",
                "I want to extend my sincerest apologies for the negative experience that you had.",
                "I hope you will accept my sincere apologies for the inconvenience you experienced."
            ];
            let apologySelection = apologyMessages[Math.floor(Math.random() * apologyMessages.length)];
            return apologySelection;
        }
        /** 
         * @var {string} apology  
         * @summary randomly selected an apology from the list of apologyMessages
         */         
        let apology = pickApology();       
        message.channel.send(`${args}, on behalf of ${message.author}, ${apology}`);
    }
};