Skip to content

Commit

Permalink
Expose flags on MessageEdit so you can suppress embeds on other messa…
Browse files Browse the repository at this point in the history
…ges (#973)

* Expose Flags on MessageEdit and add SuppressEmbeds

Also fix typo in the message flags enum

* Fix deprecation comment

* Add omitempty to Flags member

I wasn't sure if this was going to work but the documentation says:

> The "omitempty" option specifies that the field should be omitted from the encoding if the field has an empty value, defined as false, 0, a nil pointer, a nil interface value, and any empty array, slice, map, or string.

Therefore, if Flags is unmodified it will be omitted.

* Make Components omitempty

I think the null value here may be triggering the "Cannot edit a message authored by another user"

* Remove convenience function for now

* Move deprecated member out of list

Stops the gofmt error

* Fix golint issue

* Change deprecation comment

* feat: code review changes

Co-authored-by: nitroflap <fe.lap.prog@gmail.com>
  • Loading branch information
nixxquality and FedorLap2006 committed Apr 14, 2022
1 parent c615fc7 commit b138df6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion message.go
Expand Up @@ -199,7 +199,9 @@ const (
MessageFlagsCrossPosted MessageFlags = 1 << 0
// MessageFlagsIsCrossPosted this message originated from a message in another channel (via Channel Following).
MessageFlagsIsCrossPosted MessageFlags = 1 << 1
// MessageFlagsSupressEmbeds do not include any embeds when serializing this message.
// MessageFlagsSuppressEmbeds do not include any embeds when serializing this message.
MessageFlagsSuppressEmbeds MessageFlags = 1 << 2
// TODO: deprecated, remove when compatibility is not needed
MessageFlagsSupressEmbeds MessageFlags = 1 << 2
// MessageFlagsSourceMessageDeleted the source message for this crosspost has been deleted (via Channel Following).
MessageFlagsSourceMessageDeleted MessageFlags = 1 << 3
Expand Down Expand Up @@ -246,6 +248,7 @@ type MessageEdit struct {
Components []MessageComponent `json:"components"`
Embeds []*MessageEmbed `json:"embeds"`
AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
Flags MessageFlags `json:"flags,omitempty"`

ID string
Channel string
Expand Down

0 comments on commit b138df6

Please sign in to comment.