public static GuildRoleEntity Clone(this GuildRoleEntity entity) => new GuildRoleEntity() { RoleId = entity.RoleId, GuildId = entity.GuildId, Name = entity.Name, Position = entity.Position };
public static void ShouldNotHaveChanged(this GuildRoleEntity entity) { entity.ShouldNotBeNull(); entity.RoleId.ShouldBeOneOf(GuildRoles.Entities.Select(x => x.RoleId).ToArray()); var originalEntity = GuildRoles.Entities.First(x => x.RoleId == entity.RoleId); entity.GuildId.ShouldBe(originalEntity.GuildId); entity.Name.ShouldBe(originalEntity.Name); entity.Position.ShouldBe(originalEntity.Position); }
private async Task <bool> CanUserMaintainTagOwnedByRoleAsync(IGuildUser currentUser, GuildRoleEntity ownerRole) { Debug.Assert(!(ownerRole is null)); var rankRoles = await GetRankRolesAsync(currentUser.GuildId); // If the owner role is no longer ranked, everything outranks it. if (!rankRoles.Any(x => x.Id == ownerRole.RoleId)) { return(true); } var currentUserRankRoles = rankRoles.Where(r => currentUser.RoleIds.Contains(r.Id)); var currentUserMaxRank = currentUserRankRoles.Any() ? currentUserRankRoles.Select(x => x.Position).Max() : int.MinValue; // Only allow maintenance if the user has sufficient rank. return(currentUserMaxRank >= ownerRole.Position); }
internal void ApplyTo(GuildRoleEntity entity) { entity.Name = Name; entity.Position = Position; }
internal static GuildRoleMutationData FromEntity(GuildRoleEntity entity) => new GuildRoleMutationData() { Name = entity.Name, Position = entity.Position };