Commander register api
talking about permissions, im working on the registering api for the Commander, and I wanted to ask for some general feedback: if it makes sense, if I might be missing something obvious, possible ideas for something to add, you name it.
9 Replies
So, if roles/permissions/anyPermission get merged into a single function, it would look something like this:
maybe I could send the same args to the
canRunIt
function like to handler, in case they want to allow/forbid depending on some command arg. Can't think of a use case, but if Im already parsing it for A, I can send it for B 🤷♂️
That's the most versatile option, but it's certainly a lot simpler for Commander to have user roles to compare or the likeEh not sure if its easier or no. For me it's certainly easier to offload that, I just call the function, if it returns true, good, if not, don't show it, and voilá
True, I'm imagining a world where someone is going to want to do async permissions calls
(which could be a pita)
on second thought about the params to the permissions func, if I want to send the args, I need to show them the function all the time, and forbit it after trying to run it.
so I think its better to at least initially just be a () => boolean
Yeah that's unnecessary IMO. The handler can escape hatch out if it gets that far
yeah ofc.. this would all run inside a huge try-catch, and if anything smells funny I will just show a message and abort
Oh a callback would actually be simple for you...
You could filter using that cb as the return.
to filter command suggestions? yeah indeed
You will need to define when that check happens though, whether it's cached at load or when the user first opens the menu, etc.
As long as you define it in the docs, whatever you pick will be powerful
Changing lanes, the suggestion callback would benefit from having the current arguments, you could suggest different things based on the current input
I'll probably do it at module start, just before calling the
commanderReady
hook, comparing against the known list of commands, and then refresh it on any additional registration.
oh that's good
I thought of it like "this is supposed to be a Player Character, go and fetch all PCs", but you could even use one arg to puppet the others with some hocus pocus