// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// BotsSetBotCommandsRequest represents TL type `bots.setBotCommands#517165a`.
// Set bot command list
//
// See https://core.telegram.org/method/bots.setBotCommands for reference.
type BotsSetBotCommandsRequest struct {
	// Command scope
	Scope BotCommandScopeClass
	// Language code
	LangCode string
	// Bot commands
	Commands []BotCommand
}

// BotsSetBotCommandsRequestTypeID is TL type id of BotsSetBotCommandsRequest.
const BotsSetBotCommandsRequestTypeID = 0x517165a

// Ensuring interfaces in compile-time for BotsSetBotCommandsRequest.
var (
	_ bin.Encoder     = &BotsSetBotCommandsRequest{}
	_ bin.Decoder     = &BotsSetBotCommandsRequest{}
	_ bin.BareEncoder = &BotsSetBotCommandsRequest{}
	_ bin.BareDecoder = &BotsSetBotCommandsRequest{}
)

func ( *BotsSetBotCommandsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Scope == nil) {
		return false
	}
	if !(.LangCode == "") {
		return false
	}
	if !(.Commands == nil) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *BotsSetBotCommandsRequest) () string {
	if  == nil {
		return "BotsSetBotCommandsRequest(nil)"
	}
	type  BotsSetBotCommandsRequest
	return fmt.Sprintf("BotsSetBotCommandsRequest%+v", (*))
}

// FillFrom fills BotsSetBotCommandsRequest from given interface.
func ( *BotsSetBotCommandsRequest) ( interface {
	() ( BotCommandScopeClass)
	() ( string)
	() ( []BotCommand)
}) {
	.Scope = .()
	.LangCode = .()
	.Commands = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*BotsSetBotCommandsRequest) () uint32 {
	return BotsSetBotCommandsRequestTypeID
}

// TypeName returns name of type in TL schema.
func (*BotsSetBotCommandsRequest) () string {
	return "bots.setBotCommands"
}

// TypeInfo returns info about TL type.
func ( *BotsSetBotCommandsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "bots.setBotCommands",
		ID:   BotsSetBotCommandsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Scope",
			SchemaName: "scope",
		},
		{
			Name:       "LangCode",
			SchemaName: "lang_code",
		},
		{
			Name:       "Commands",
			SchemaName: "commands",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *BotsSetBotCommandsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.setBotCommands#517165a as nil")
	}
	.PutID(BotsSetBotCommandsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotsSetBotCommandsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.setBotCommands#517165a as nil")
	}
	if .Scope == nil {
		return fmt.Errorf("unable to encode bots.setBotCommands#517165a: field scope is nil")
	}
	if  := .Scope.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.setBotCommands#517165a: field scope: %w", )
	}
	.PutString(.LangCode)
	.PutVectorHeader(len(.Commands))
	for ,  := range .Commands {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode bots.setBotCommands#517165a: field commands element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *BotsSetBotCommandsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.setBotCommands#517165a to nil")
	}
	if  := .ConsumeID(BotsSetBotCommandsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode bots.setBotCommands#517165a: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *BotsSetBotCommandsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.setBotCommands#517165a to nil")
	}
	{
		,  := DecodeBotCommandScope()
		if  != nil {
			return fmt.Errorf("unable to decode bots.setBotCommands#517165a: field scope: %w", )
		}
		.Scope = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode bots.setBotCommands#517165a: field lang_code: %w", )
		}
		.LangCode = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode bots.setBotCommands#517165a: field commands: %w", )
		}

		if  > 0 {
			.Commands = make([]BotCommand, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  BotCommand
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode bots.setBotCommands#517165a: field commands: %w", )
			}
			.Commands = append(.Commands, )
		}
	}
	return nil
}

// GetScope returns value of Scope field.
func ( *BotsSetBotCommandsRequest) () ( BotCommandScopeClass) {
	if  == nil {
		return
	}
	return .Scope
}

// GetLangCode returns value of LangCode field.
func ( *BotsSetBotCommandsRequest) () ( string) {
	if  == nil {
		return
	}
	return .LangCode
}

// GetCommands returns value of Commands field.
func ( *BotsSetBotCommandsRequest) () ( []BotCommand) {
	if  == nil {
		return
	}
	return .Commands
}

// BotsSetBotCommands invokes method bots.setBotCommands#517165a returning error if any.
// Set bot command list
//
// Possible errors:
//
//	400 BOT_COMMAND_DESCRIPTION_INVALID: The specified command description is invalid.
//	400 BOT_COMMAND_INVALID: The specified command is invalid.
//	400 LANG_CODE_INVALID: The specified language code is invalid.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 USER_BOT_REQUIRED: This method can only be called by a bot.
//	400 USER_ID_INVALID: The provided user ID is invalid.
//
// See https://core.telegram.org/method/bots.setBotCommands for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *BotsSetBotCommandsRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}