/// <summary> /// Gets all restrictions related to a user, or NONE if the <paramref name="UserID"/> is not in the database. /// </summary> /// <param name="UserID">The ID of the target user to fetch from the database.</param> /// <returns>.</returns> public Restriction GetUserRestrictions(ulong UserID) { UserRestriction UR = UserRestrictions.Find(UserID); if (UR == null) { return(Restriction.None); } return(UR.RestrictionFlags); }
/// <summary> /// Removes a set of restrictions <paramref name="Restriction"/> from a user given by <paramref name="UserID"/>. /// </summary> /// <param name="UserID">The target user's unique ID.</param> /// <param name="Restriction">The Restriction flags to remove from User.</param> /// <returns><see langword="true"/> if the restriction was removed, <see langword="false"/> if the user wasn't in the database or didn't have that restriction.</returns> public bool RemoveRestriction(ulong UserID, Restriction Restriction) { UserRestriction UR = UserRestrictions.Find(UserID); if (UR == null) { return(false); } if ((UR.RestrictionFlags & Restriction) == Restriction.None) { return(false); } UR.RestrictionFlags &= ~Restriction; return(true); }
/// <summary> /// Adds a given <paramref name="Restriction"/> to a user's registry, and creates a new one if none exists for the given user by <paramref name="UserID"/>. /// </summary> /// <param name="UserID">The ID of the target User.</param> /// <param name="Restriction">The Restriction flags to add to the User.</param> /// <returns><see langword="false"/> if the user already had that <paramref name="Restriction"/>, otherwise <see langword="true"/>.</returns> public bool AddRestriction(ulong UserID, Restriction Restriction) { UserRestriction UR = UserRestrictions.Find(UserID); if (UR == null) { UR = new() { UserID = UserID, RestrictionFlags = Restriction }; UserRestrictions.Add(UR); return(true); } if ((UR.RestrictionFlags | Restriction) == UR.RestrictionFlags) { return(false); } UR.RestrictionFlags |= Restriction; return(true); }