public static bool CheckToMask(this AccountRoles role, AccountRoles mask) { if (mask.HasFlag(AccountRoles.Anonymous) || mask.HasFlag(AccountRoles.Banned)) { // Commands with these roles are accessible for everyone (even for banned users) return(true); } return(!role.HasFlag(AccountRoles.Banned) && (role & mask) != 0); }
public static HashSet <string> ToRoleSet(this AccountRoles roles) { var res = new HashSet <string>(); foreach (AccountRoles token in Enum.GetValues(typeof(AccountRoles))) { if (token == AccountRoles.None) { continue; } if (roles.HasFlag(token)) { res.Add(token.ToString()); } } return(res); }