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(buttons)!: omit empty emoji field #1475

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions components.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ type ComponentEmoji struct {

// Button represents button component.
type Button struct {
Label string `json:"label"`
Style ButtonStyle `json:"style"`
Disabled bool `json:"disabled"`
Emoji ComponentEmoji `json:"emoji"`
Label string `json:"label"`
Style ButtonStyle `json:"style"`
Disabled bool `json:"disabled"`
Emoji *ComponentEmoji `json:"emoji,omitempty"`

// NOTE: Only button with LinkButton style can have link. Also, URL is mutually exclusive with CustomID.
URL string `json:"url,omitempty"`
Expand Down
18 changes: 9 additions & 9 deletions examples/components/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,23 @@ var (
discordgo.ActionsRow{
Components: []discordgo.MessageComponent{
discordgo.Button{
Emoji: discordgo.ComponentEmoji{
Emoji: &discordgo.ComponentEmoji{
Name: "📜",
},
Label: "Documentation",
Style: discordgo.LinkButton,
URL: "https://discord.com/developers/docs/interactions/message-components#buttons",
},
discordgo.Button{
Emoji: discordgo.ComponentEmoji{
Emoji: &discordgo.ComponentEmoji{
Name: "🔧",
},
Label: "Discord developers",
Style: discordgo.LinkButton,
URL: "https://discord.gg/discord-developers",
},
discordgo.Button{
Emoji: discordgo.ComponentEmoji{
Emoji: &discordgo.ComponentEmoji{
Name: "🦫",
},
Label: "Discord Gophers",
Expand All @@ -88,15 +88,15 @@ var (
discordgo.ActionsRow{
Components: []discordgo.MessageComponent{
discordgo.Button{
Emoji: discordgo.ComponentEmoji{
Emoji: &discordgo.ComponentEmoji{
Name: "🔧",
},
Label: "Discord developers",
Style: discordgo.LinkButton,
URL: "https://discord.gg/discord-developers",
},
discordgo.Button{
Emoji: discordgo.ComponentEmoji{
Emoji: &discordgo.ComponentEmoji{
Name: "🦫",
},
Label: "Discord Gophers",
Expand Down Expand Up @@ -182,23 +182,23 @@ var (
discordgo.ActionsRow{
Components: []discordgo.MessageComponent{
discordgo.Button{
Emoji: discordgo.ComponentEmoji{
Emoji: &discordgo.ComponentEmoji{
Name: "📜",
},
Label: "Documentation",
Style: discordgo.LinkButton,
URL: "https://discord.com/developers/docs/interactions/message-components#select-menus",
},
discordgo.Button{
Emoji: discordgo.ComponentEmoji{
Emoji: &discordgo.ComponentEmoji{
Name: "🔧",
},
Label: "Discord developers",
Style: discordgo.LinkButton,
URL: "https://discord.gg/discord-developers",
},
discordgo.Button{
Emoji: discordgo.ComponentEmoji{
Emoji: &discordgo.ComponentEmoji{
Name: "🦫",
},
Label: "Discord Gophers",
Expand Down Expand Up @@ -251,7 +251,7 @@ var (
Disabled: false,
// Link buttons don't require CustomID and do not trigger the gateway/HTTP event
URL: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
Emoji: discordgo.ComponentEmoji{
Emoji: &discordgo.ComponentEmoji{
Name: "🤷",
},
},
Expand Down