Add files to MessageEdit (#1253)
* Add files to MessageEdit * Remove files from json 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:
parent
1ff58d47ef
commit
410cf4fac5
2 changed files with 17 additions and 1 deletions
|
@ -249,6 +249,10 @@ type MessageEdit struct {
|
|||
Embeds []*MessageEmbed `json:"embeds"`
|
||||
AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
|
||||
Flags MessageFlags `json:"flags,omitempty"`
|
||||
// Files to append to the message
|
||||
Files []*File `json:"-"`
|
||||
// Overwrite existing attachments
|
||||
Attachments *[]*MessageAttachment `json:"attachments,omitempty"`
|
||||
|
||||
ID string
|
||||
Channel string
|
||||
|
|
14
restapi.go
14
restapi.go
|
@ -1729,7 +1729,19 @@ func (s *Session) ChannelMessageEditComplex(m *MessageEdit) (st *Message, err er
|
|||
embed.Type = "rich"
|
||||
}
|
||||
}
|
||||
response, err := s.RequestWithBucketID("PATCH", EndpointChannelMessage(m.Channel, m.ID), m, EndpointChannelMessage(m.Channel, ""))
|
||||
|
||||
endpoint := EndpointChannelMessage(m.Channel, m.ID)
|
||||
|
||||
var response []byte
|
||||
if len(m.Files) > 0 {
|
||||
contentType, body, encodeErr := MultipartBodyWithJSON(m, m.Files)
|
||||
if encodeErr != nil {
|
||||
return st, encodeErr
|
||||
}
|
||||
response, err = s.request("PATCH", endpoint, contentType, body, EndpointChannelMessage(m.Channel, ""), 0)
|
||||
} else {
|
||||
response, err = s.RequestWithBucketID("PATCH", endpoint, m, EndpointChannelMessage(m.Channel, ""))
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue