You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: tl_chat_members_gen.go
    path of file: ./repos/td/tdapi
    
    the code of the file until where you have to start completion: // Code generated by gotdgen, DO NOT EDIT.

package tdapi

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"github.com/gotd/td/bin"
	"github.com/gotd/td/tdjson"
	"github.com/gotd/td/tdp"

    
func (c *ChatMembers) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatMembers#8ecbb24 as nil")
	}
	b.PutInt32(c.TotalCount)
	b.PutInt(len(c.Members))
	for idx, v := range c.Members {
		if err := v.EncodeBare(b); err != nil {
			return fmt.Errorf("unable to encode bare chatMembers#8ecbb24: field members element with index %d: %w", idx, err)
		}
	}
	return nil
}