The best way to promote a user to a needed role

Hi everyone!
In my code I need to promote a user to the super admin role before another user leaves a group. I know about the nk.GroupUsersPromote method, and I have a userID of a user to promote. But I haven’t his current role or his role after the nk.GroupUsersPromote operation. So, to complete this simple operation, I need to get user’s current role, then I need to complete nk.GroupUsersPromote * prevUserRole times. Or I need to promote user and after each success operation I need to get his state to check if he has the needed state. Is there more optimized way to do this operation? For example it would be great to have some method like nk.GroupUserSetState(userID, state int). If there is no such a method, how do you think, should I create an issue on the github to add this method?

1 Like

Hello @Andrey,

I don’t believe there’s a better way to achieve this currently, I think this is a valid use-case, please open an issue on Github that we can track so that we can improve or add a new API to handle this in the future.

EDIT: A slightly better way to achieve this would be to get the current state of the user, calculate how many times you need to call the Promote/Demote user APIs depending on which role you want to grant and then call it that many times.


1 Like

I have created an issue: Feature request: method to promote a group member to a specified role. · Issue #1004 · heroiclabs/nakama · GitHub