Skip to content

Commit

Permalink
fix(buttons)!: omit empty emoji field (#1475)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGrandPackard authored Jan 4, 2024
1 parent 1ffd696 commit f70a015
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
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

0 comments on commit f70a015

Please sign in to comment.