diff --git a/lib/facebot.js b/lib/facebot.js index 66bdeeb..e3021ff 100644 --- a/lib/facebot.js +++ b/lib/facebot.js @@ -390,7 +390,7 @@ Facebot.prototype.respondToCreateChatMessages = function(message) { .fail(err => { return this.postMessage( message.channel, - `Unable to connect the chat: ${err.error}`, + `Unable to connect the chat: ${err.message}`, { as_user: true } ); }); diff --git a/lib/util.js b/lib/util.js index a49700c..e40e3e2 100644 --- a/lib/util.js +++ b/lib/util.js @@ -13,13 +13,11 @@ async function findFBUser(api, search_str, allowNonFriends) { // If the search string isnt a userID, we should search // for the user by name if (!USER_ID_REGEX.test(search_str)) { - let userData = await Q.nfcall(api.getUserID, name); + let userData = await Q.nfcall(api.getUserID, search_str); userID = userData[0].userID; } - const userInfoMap = await getFBUserInfoByID(api, userID); const userInfo = userInfoMap[userID]; - if (!userInfo.isFriend && !allowNonFriends) throw new Error( 'User not your friend, they may not be your top ' + @@ -28,8 +26,7 @@ async function findFBUser(api, search_str, allowNonFriends) { ); // The userinfo object doesnt have an id with it, so add it as its useful - userID.id = userID; - + userInfo.id = userID; return userInfo; }