Botkit: Callback was already called

Created on 1 May 2017  路  4Comments  路  Source: howdyai/botkit

Code

controller.hears(['leaderboard'], 'direct_mention', (bot, message) => {

    controller.storage.users.all(function(err, users) {

      if (err) {
        bot.reply(message, `I goofed! \`\`\`${err}\`\`\``);
        return false;
      } else {

      var text = generateLeaderboard(users);

      bot.reply(message, text);

    });

});

function generateLeaderboard(users) {
  var text = '';
  for (var t = 0; t < users.length; t++) {
    text = text + `${user.id} \n`;
  }
  return text;
}

Error

/Users/user/test-bot/node_modules/jfs/node_modules/async/lib/async.js:38
            if (called) throw new Error("Callback was already called.");
                        ^

Error: Callback was already called.
    at /Users/user/test-bot/node_modules/jfs/node_modules/async/lib/async.js:38:31
    at /Users/user/test-bot/node_modules/jfs/node_modules/async/lib/async.js:679:17
    at /Users/user/test-bot/node_modules/jfs/lib/Store.js:388:30
    at /Users/user/test-bot/node_modules/jfs/lib/Store.js:211:20
    at /Users/user/test-bot/node_modules/jfs/lib/Store.js:100:16
    at tryToString (fs.js:455:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12)

Botkit version: 0.5.4
OS Version: OSX 10.11.6

help wanted

Most helpful comment

not sure if this would help, but you are missing the closing } for your else statement

All 4 comments

Did anyone find a solution to this

@taherPardawala I never found a solution to this, so had to remove the function and bring it all inline.

not sure if this would help, but you are missing the closing } for your else statement

@nsantini I can't believe I didn't see this :man_facepalming:

Was this page helpful?
0 / 5 - 0 ratings