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

fix(message)!: omit empty Components and Embeds #1483

Merged
merged 6 commits into from
Feb 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ type MessageSend struct {
Content string `json:"content,omitempty"`
Embeds []*MessageEmbed `json:"embeds"`
TTS bool `json:"tts"`
Components []MessageComponent `json:"components"`
Components []*MessageComponent `json:"components"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

MessageComponent is an interface. If the array going to consist of pointers, it's going to be extremely inconvenient to pass things in.

var btn discordgo.MessageComponent = discordgo.Button{}
components := []*discordgo.MessageComponent{
    discordgo.Button{...}, // Not possible
    &btn,
}

Files []*File `json:"-"`
AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
Reference *MessageReference `json:"message_reference,omitempty"`
Expand All @@ -251,8 +251,8 @@ type MessageSend struct {
// is also where you should get the instance from.
type MessageEdit struct {
Content *string `json:"content,omitempty"`
Components []MessageComponent `json:"components"`
Embeds []*MessageEmbed `json:"embeds"`
Components []*MessageComponent `json:"components,omitempty"`
AlexeyOplachko marked this conversation as resolved.
Show resolved Hide resolved
Embeds []*MessageEmbed `json:"embeds,omitempty"`
AlexeyOplachko marked this conversation as resolved.
Show resolved Hide resolved
AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
Flags MessageFlags `json:"flags,omitempty"`
// Files to append to the message
Expand Down