anjanms / DubAPI

A Node.js API for creating queup.net bots.
MIT License
20 stars 10 forks source link

cannot call hasPermission of undefined #12

Closed BenWildeman closed 8 years ago

BenWildeman commented 8 years ago

getting the following error when trying to delete a chat message: error using 1.0.3

anjanms commented 8 years ago

Did the bot ban someone before this happened? Currently there is an issue with dubtrack where the server sends a user-leave event for the moderator instead of the user that was banned.

And this error is caused by the bot not being in the user array for the room anymore.

BenWildeman commented 8 years ago

no it hasn't. it sometimes seems to lose self from the user array. it's happened 5 times now, 2 in a row where the bot crashed then auto restarted, then crashed again when invoked

On 11 December 2015 at 20:18, anjanms notifications@github.com wrote:

Did the bot ban someone before this happened? Currently there is an issue with dubtrack where the server sends a user-leave event for the moderator instead of the user that was banned.

And this error is caused by the bot not being in the user array for the room anymore.

— Reply to this email directly or view it on GitHub https://github.com/anjanms/DubAPI/issues/12#issuecomment-164038350.

anjanms commented 8 years ago

Alright. All the stacktraces were similar to the one you provided? How much time was there between the bot connecting and it crashing again when calling moderateDeleteChat?

BenWildeman commented 8 years ago

yeah they were the same stacktraces. and 2 mins or so

On 11 December 2015 at 21:11, anjanms notifications@github.com wrote:

Alright. All the stacktraces were similar to the one you provided? How much time was there between the bot connecting and it crashing when calling moderateDeleteChat?

— Reply to this email directly or view it on GitHub https://github.com/anjanms/DubAPI/issues/12#issuecomment-164048607.

anjanms commented 8 years ago

Okay, I can't seem reproduce this. I can remove the bot from the array and get the same error, but I can't get it to happen on it's own. Do you notice anything common happen before each of these errors?

If not, can you add the following lines to listeners on the connected and user-leave events respectively? Change them to your logger if you've got one.

console.log('[DEBUG]', 'Bot ID is: ' + bot._.self.id);
if (bot._.room.users.findWhere({id: bot._.self.id}, true) === undefined) {
    console.log('[DEBUG]', 'Bot not in room');
}
//Where data is the object passed to the event
if (data.user.id === bot._.self.id) {
    console.log('[DEBUG]', 'Bot left the room');
}

Make sure the ID printed matches the account of your bot.

One of the other messages should print before that error occurs again. Let me know which one, and in the case of it leaving I'll need to know what happened just before.

BenWildeman commented 8 years ago

yeah I'll add those to my bot and see if they crop up at some point. the delete chat command doesn't get used often but I'll test periodically until it breaks

BenWildeman commented 8 years ago

alright finally got it. it's leaving the room apparently

anjanms commented 8 years ago

Alright. Did you notice anything aside from usual advancing/chatting/voting happen around the time the bot left?

Updating to 1.1.0 should resolve this symptom. The API will request to re-join the room when a leave event is received for the bot.