From b138df6efe8b8e35f5a10830270f3a32362434dc Mon Sep 17 00:00:00 2001 From: nixxquality Date: Thu, 14 Apr 2022 22:33:51 +0200 Subject: [PATCH] Expose flags on MessageEdit so you can suppress embeds on other messages (#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 --- message.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/message.go b/message.go index 535e506..22d5f74 100644 --- a/message.go +++ b/message.go @@ -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 @@ -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