// 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{}
)

// MessagesSetGameScoreRequest represents TL type `messages.setGameScore#8ef8ecc0`.
// Use this method to set the score of the specified user in a game sent as a normal
// message (bots only).
//
// See https://core.telegram.org/method/messages.setGameScore for reference.
type MessagesSetGameScoreRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Set this flag if the game message should be automatically edited to include the
	// current scoreboard
	EditMessage bool
	// Set this flag if the high score is allowed to decrease. This can be useful when fixing
	// mistakes or banning cheaters
	Force bool
	// Unique identifier of target chat
	Peer InputPeerClass
	// Identifier of the sent message
	ID int
	// User identifier
	UserID InputUserClass
	// New score
	Score int
}

// MessagesSetGameScoreRequestTypeID is TL type id of MessagesSetGameScoreRequest.
const MessagesSetGameScoreRequestTypeID = 0x8ef8ecc0

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

func ( *MessagesSetGameScoreRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.EditMessage == false) {
		return false
	}
	if !(.Force == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.UserID == nil) {
		return false
	}
	if !(.Score == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSetGameScoreRequest from given interface.
func ( *MessagesSetGameScoreRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( InputPeerClass)
	() ( int)
	() ( InputUserClass)
	() ( int)
}) {
	.EditMessage = .()
	.Force = .()
	.Peer = .()
	.ID = .()
	.UserID = .()
	.Score = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesSetGameScoreRequest) () string {
	return "messages.setGameScore"
}

// TypeInfo returns info about TL type.
func ( *MessagesSetGameScoreRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.setGameScore",
		ID:   MessagesSetGameScoreRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "EditMessage",
			SchemaName: "edit_message",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Force",
			SchemaName: "force",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Score",
			SchemaName: "score",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesSetGameScoreRequest) () {
	if !(.EditMessage == false) {
		.Flags.Set(0)
	}
	if !(.Force == false) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesSetGameScoreRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setGameScore#8ef8ecc0 as nil")
	}
	.PutID(MessagesSetGameScoreRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSetGameScoreRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setGameScore#8ef8ecc0 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setGameScore#8ef8ecc0: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.setGameScore#8ef8ecc0: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setGameScore#8ef8ecc0: field peer: %w", )
	}
	.PutInt(.ID)
	if .UserID == nil {
		return fmt.Errorf("unable to encode messages.setGameScore#8ef8ecc0: field user_id is nil")
	}
	if  := .UserID.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setGameScore#8ef8ecc0: field user_id: %w", )
	}
	.PutInt(.Score)
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesSetGameScoreRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.setGameScore#8ef8ecc0 to nil")
	}
	if  := .ConsumeID(MessagesSetGameScoreRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.setGameScore#8ef8ecc0: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSetGameScoreRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.setGameScore#8ef8ecc0 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.setGameScore#8ef8ecc0: field flags: %w", )
		}
	}
	.EditMessage = .Flags.Has(0)
	.Force = .Flags.Has(1)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setGameScore#8ef8ecc0: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setGameScore#8ef8ecc0: field id: %w", )
		}
		.ID = 
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setGameScore#8ef8ecc0: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setGameScore#8ef8ecc0: field score: %w", )
		}
		.Score = 
	}
	return nil
}

// SetEditMessage sets value of EditMessage conditional field.
func ( *MessagesSetGameScoreRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.EditMessage = true
	} else {
		.Flags.Unset(0)
		.EditMessage = false
	}
}

// GetEditMessage returns value of EditMessage conditional field.
func ( *MessagesSetGameScoreRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetForce sets value of Force conditional field.
func ( *MessagesSetGameScoreRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Force = true
	} else {
		.Flags.Unset(1)
		.Force = false
	}
}

// GetForce returns value of Force conditional field.
func ( *MessagesSetGameScoreRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// GetPeer returns value of Peer field.
func ( *MessagesSetGameScoreRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetID returns value of ID field.
func ( *MessagesSetGameScoreRequest) () ( int) {
	if  == nil {
		return
	}
	return .ID
}

// GetUserID returns value of UserID field.
func ( *MessagesSetGameScoreRequest) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .UserID
}

// GetScore returns value of Score field.
func ( *MessagesSetGameScoreRequest) () ( int) {
	if  == nil {
		return
	}
	return .Score
}

// MessagesSetGameScore invokes method messages.setGameScore#8ef8ecc0 returning error if any.
// Use this method to set the score of the specified user in a game sent as a normal
// message (bots only).
//
// Possible errors:
//
//	400 BOT_SCORE_NOT_MODIFIED: The score wasn't modified.
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 SCORE_INVALID: The specified game score is invalid.
//	400 USER_BOT_REQUIRED: This method can only be called by a bot.
//
// See https://core.telegram.org/method/messages.setGameScore for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesSetGameScoreRequest) (UpdatesClass, error) {
	var  UpdatesBox

	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return .Updates, nil
}