Schmavery / facebook-chat-api

Unofficial Facebook Chat API for Nodejs
MIT License
1.94k stars 596 forks source link

Unhandled rejection TypeError: Cannot read properties of undefined (reading 'messageCount') #900

Closed tddaij closed 2 years ago

tddaij commented 2 years ago

api.listenMqtt(function callback(err, message) { api.getThreadInfo(message.threadID, function(err, thread) { if (message.body === "count") { api.sendMessage("Total: " + thread.messageCount, message.threadID); } }); });

BadAimWeeb commented 2 years ago

your account has been blocked for calling API too much. do not call API before checking if the message is the command to bot.

api.listenMqtt(function callback(err, message) {
    if (message.body === "count") {
        api.getThreadInfo(message.threadID, function (err, thread) {
            if (err) {
                // Blocked?
                return console.error(err);
            }
            api.sendMessage(`Total: ${thread.messageCount}`, message.threadID);
        });
    }
}