anjanms / DubAPI

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

disconnect TypeError #34

Closed FranciscoG closed 7 years ago

FranciscoG commented 7 years ago

I'm seeing this error happen often when it tries to disconnect:

    /home/user/www/DerpyBot/node_modules/dubapi/index.js:128
    0|bot      |     this._.sokHandler.detachChannel('room:' + this._.room.id);
    0|bot      |                                                          ^
    0|bot      | TypeError: Cannot read property 'id' of undefined
    0|bot      |     at DubAPI.disconnect (/home/user/www/DerpyBot/node_modules/dubapi/index.js:128:58)
    0|bot      |     at process.disconnect (/home/ciscog/www/DerpyBot/bot/index.js:46:13)

Happens at this line.

Maybe move that line inside the conditional block right below it like this?

    if (this._.room) {
        this._.sokHandler.detachChannel('room:' + this._.room.id);
        clearTimeout(this._.room.playTimeout);
        this._.reqHandler.queue({method: 'DELETE', url: endpoints.roomUsers});
    }