Added stickers to type MessageSend (#1340)

* Added stickers to type MessageSend

* Update restapi.go

Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>

* Update message.go

Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>

---------

Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>
This commit is contained in:
Yara McRobert 2023-04-04 16:30:57 +01:00 committed by GitHub
parent cd4f875097
commit b7c431c368
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -233,6 +233,7 @@ type MessageSend struct {
Files []*File `json:"-"`
AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
Reference *MessageReference `json:"message_reference,omitempty"`
StickerIDs []string `json:"sticker_ids"`
// TODO: Remove this when compatibility is not required.
File *File `json:"-"`

View file

@ -1700,13 +1700,19 @@ func (s *Session) ChannelMessageSendComplex(channelID string, data *MessageSend,
}
}
if data.StickerIDs != nil {
if len(data.StickerIDs) > 3 {
err = fmt.Errorf("cannot send more than 3 stickers")
return
}
}
var response []byte
if len(files) > 0 {
contentType, body, encodeErr := MultipartBodyWithJSON(data, files)
if encodeErr != nil {
return st, encodeErr
}
response, err = s.request("POST", endpoint, contentType, body, endpoint, 0, options...)
} else {
response, err = s.RequestWithBucketID("POST", endpoint, data, endpoint, options...)