siscodeorg / sisbase

An easy to use discord bot base for D#+. Discord Link :
https://discord.gg/ycvm6xJ
MIT License
1 stars 0 forks source link

Improve HierarchyUtils #45

Open alikindsys opened 4 years ago

alikindsys commented 4 years ago

Add extensions for getting the highest role with a given permission and allow predicates on GetHighestRole

-- Role GetHighestRole(this Member m);
++ Role GetHighestRole(this Member m, Func<Role,bool> pred);
++ Role GetHighestRole(this Member m) => m.GetHighestRole(_ => true);
++ Role GetHighestRoleWithPermission(this Member m , Perm p) => m.GetHighestRole(x => x.HasPermission(p));
alikindsys commented 4 years ago

Maybe consider also GetLowestRole and GetLowestRoleWithPermission

++ Role GetLowestRole(this Member m,Func<Role,bool> pred);
++ Role GetLowestRole(this Member m) => m.GetLowestRole(_ => true);
++ Role GetLowestRoleWithPermission(this Member m,Perm p) => m.GetLowestRole(x => x.HasPermission(p);
wffirilat commented 4 years ago

Does the lowest role of a member have any significance? It seems to me that the lowest role is no different than any other roll that isn't the highest when it comes to actual permissions. If anything, I'd worry that the existence of an explicit GetLowestRole would make people write very unintuitive code that doesn't match default discord behaviour at all.

alikindsys commented 4 years ago

Fair point, thanks for reminding why it weren't implemented in the first place.