Skip to content

Commit

Permalink
Build ButtonComponents instead of using the helper (#364)
Browse files Browse the repository at this point in the history
* Build ButtonComponents instead of using the helper

* whoops
  • Loading branch information
sebm253 authored Jun 15, 2024
1 parent 1087c1a commit 7380d44
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions discord/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,27 +248,47 @@ func NewButton(style ButtonStyle, label string, customID string, url string) But

// NewPrimaryButton creates a new ButtonComponent with ButtonStylePrimary & the provided parameters
func NewPrimaryButton(label string, customID string) ButtonComponent {
return NewButton(ButtonStylePrimary, label, customID, "")
return ButtonComponent{
Style: ButtonStylePrimary,
Label: label,
CustomID: customID,
}
}

// NewSecondaryButton creates a new ButtonComponent with ButtonStyleSecondary & the provided parameters
func NewSecondaryButton(label string, customID string) ButtonComponent {
return NewButton(ButtonStyleSecondary, label, customID, "")
return ButtonComponent{
Style: ButtonStyleSecondary,
Label: label,
CustomID: customID,
}
}

// NewSuccessButton creates a new ButtonComponent with ButtonStyleSuccess & the provided parameters
func NewSuccessButton(label string, customID string) ButtonComponent {
return NewButton(ButtonStyleSuccess, label, customID, "")
return ButtonComponent{
Style: ButtonStyleSuccess,
Label: label,
CustomID: customID,
}
}

// NewDangerButton creates a new ButtonComponent with ButtonStyleDanger & the provided parameters
func NewDangerButton(label string, customID string) ButtonComponent {
return NewButton(ButtonStyleDanger, label, customID, "")
return ButtonComponent{
Style: ButtonStyleDanger,
Label: label,
CustomID: customID,
}
}

// NewLinkButton creates a new link ButtonComponent with ButtonStyleLink & the provided parameters
func NewLinkButton(label string, url string) ButtonComponent {
return NewButton(ButtonStyleLink, label, "", url)
return ButtonComponent{
Style: ButtonStyleLink,
Label: label,
URL: url,
}
}

var (
Expand Down

0 comments on commit 7380d44

Please sign in to comment.