:cookie: 2430 | @abhisekp | http://www.freecodecamp.com/abhisekp
const namesList = mentions.reduce((userList, mention) => {
const toUser = mention.screenName.toLowerCase();
if (toUser !== fromUser && toUser !== 'all' && userList.indexOf(toUser) === -1) {
const apiPath = '/api/users/give-brownie-points?receiver=' + toUser +
'&giver=' + fromUser;
HttpWrap.callApi(apiPath, options, thanksCommands.showInfoCallback);
userList.push(toUser);
}
return userList;
}, []);
if (namesList.length > 0) {
const toUserMessage = namesList.join(' and @');
return '> ' + fromUser + ' sends brownie points to @' + toUserMessage +
' :sparkles: :thumbsup: :sparkles: ';
} else {
return '> sorry ' + fromUser + ', you can\'t send brownie points to ' +
'yourself! :sparkles: :sparkles: ';
}