anjanms / DubAPI

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

Deep copies or another approach to allow hasPermission()? #6

Closed avatarkava closed 8 years ago

avatarkava commented 8 years ago

On plug I used to use an approach similar to user.role > 1 to say people have bouncer access or higher. Since roles are strings now, that's not possible. I could use something like user.isVIP() || user.isMod || .... but that requires a long string of function checks every time.

I did see that you have a hasPermission() function that doesn't come across when using functions like getUser() and getSelf() because they aren't set to do a deep copy of the object.

Any thoughts about either making those functions deep copies or setting up an alternate function that will grab it as needed? Currently I'm using something similar to bot._.room.users.findWhere({id: data.user.id}).hasPermission('skip') to access the property.

I can set up a PR for this if you think it's a good idea.

anjanms commented 8 years ago

Personally, I'd like to keep data returned by the API plain. And any functions on the DubAPI instance. This keeps what's reliant on the API code and what isn't clearer.

I'll happily accept a PR to add a hasPermission method on the DubAPI prototype. Just place it along with the 'is' methods.

avatarkava commented 8 years ago

Agreed on the rationale there. I'll set that up.

anjanms commented 8 years ago

Thanks!