Closed avatarkava closed 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.
Agreed on the rationale there. I'll set that up.
Thanks!
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 likeuser.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 likegetUser()
andgetSelf()
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.