Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose flags on MessageEdit so you can suppress embeds on other messages #973

Merged
merged 10 commits into from Apr 14, 2022
10 changes: 8 additions & 2 deletions message.go
Expand Up @@ -174,11 +174,16 @@ type MessageFlags int
const (
MessageFlagsCrossPosted MessageFlags = 1 << 0
MessageFlagsIsCrossPosted MessageFlags = 1 << 1
MessageFlagsSupressEmbeds MessageFlags = 1 << 2
MessageFlagsSuppressEmbeds MessageFlags = 1 << 2
MessageFlagsSourceMessageDeleted MessageFlags = 1 << 3
MessageFlagsUrgent MessageFlags = 1 << 4
)

// Deprecated: use MessageFlagsSuppressEmbeds
nixxquality marked this conversation as resolved.
Show resolved Hide resolved
const (
MessageFlagsSupressEmbeds MessageFlags = 1 << 2
)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be best to just put it right after the corrected constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I put it separate was because of a gofmt error in the previous build

0.06s$ diff <(gofmt -d .) <(echo -n)
1,14d0
< diff -u message.go.orig message.go
< --- message.go.orig	2021-07-22 08:05:45.890441692 +0000
< +++ message.go	2021-07-22 08:05:45.890441692 +0000
< @@ -172,8 +172,8 @@
<  
<  // Valid MessageFlags values
<  const (
< -	MessageFlagsCrossPosted          MessageFlags = 1 << 0
< -	MessageFlagsIsCrossPosted        MessageFlags = 1 << 1
< +	MessageFlagsCrossPosted   MessageFlags = 1 << 0
< +	MessageFlagsIsCrossPosted MessageFlags = 1 << 1
<  	// Deprecated: use MessageFlagsSuppressEmbeds
<  	MessageFlagsSupressEmbeds        MessageFlags = 1 << 2
<  	MessageFlagsSuppressEmbeds       MessageFlags = 1 << 2
The command "diff <(gofmt -d .) <(echo -n)" exited with 1.

Between messing up the spacing or extracting it to a separate section I chose the latter.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just put it at the end of the section, like that

const (
   ...
   // TODO: remove when compatibility is not required
   MessageFlagsSupressEmbeds       MessageFlags = 1 << 2
)

// File stores info about files you e.g. send in messages.
type File struct {
Name string
Expand All @@ -204,9 +209,10 @@ type MessageSend struct {
// is also where you should get the instance from.
type MessageEdit struct {
Content *string `json:"content,omitempty"`
Components []MessageComponent `json:"components"`
Components []MessageComponent `json:"components,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was intentional, to allow users to remove components from messages.
Also it would be probably better to move this into a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add this to make it work. Before I added it, Discord would give an error about "Cannot edit a message authored by another user"

This seems to be mutually exclusive with your current requirements, so I don't know what to do about that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it's related to SuppressEmbeds flag, the issue existed before, so I think it would be better to resolve this in a separate PR.

Embed *MessageEmbed `json:"embed,omitempty"`
AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
Flags MessageFlags `json:"flags,omitempty"`

ID string
Channel string
Expand Down