Skip to content

Commit 44021d1

Browse files
author
Sebastian
authored
Add ButtonStylePremium (#359)
* Add ButtonStylePremium * remove label
1 parent 7380d44 commit 44021d1

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

discord/component.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,17 @@ const (
234234
ButtonStyleSuccess
235235
ButtonStyleDanger
236236
ButtonStyleLink
237+
ButtonStylePremium
237238
)
238239

239240
// NewButton creates a new ButtonComponent with the provided parameters. Link ButtonComponent(s) need a URL and other ButtonComponent(s) need a customID
240-
func NewButton(style ButtonStyle, label string, customID string, url string) ButtonComponent {
241+
func NewButton(style ButtonStyle, label string, customID string, url string, skuID snowflake.ID) ButtonComponent {
241242
return ButtonComponent{
242243
Style: style,
243244
CustomID: customID,
244245
URL: url,
245246
Label: label,
247+
SkuID: skuID,
246248
}
247249
}
248250

@@ -291,6 +293,14 @@ func NewLinkButton(label string, url string) ButtonComponent {
291293
}
292294
}
293295

296+
// NewPremiumButton creates a new ButtonComponent with ButtonStylePremium & the provided parameters
297+
func NewPremiumButton(skuID snowflake.ID) ButtonComponent {
298+
return ButtonComponent{
299+
Style: ButtonStylePremium,
300+
SkuID: skuID,
301+
}
302+
}
303+
294304
var (
295305
_ Component = (*ButtonComponent)(nil)
296306
_ InteractiveComponent = (*ButtonComponent)(nil)
@@ -301,6 +311,7 @@ type ButtonComponent struct {
301311
Label string `json:"label,omitempty"`
302312
Emoji *ComponentEmoji `json:"emoji,omitempty"`
303313
CustomID string `json:"custom_id,omitempty"`
314+
SkuID snowflake.ID `json:"sku_id,omitempty"`
304315
URL string `json:"url,omitempty"`
305316
Disabled bool `json:"disabled,omitempty"`
306317
}
@@ -362,6 +373,12 @@ func (c ButtonComponent) WithURL(url string) ButtonComponent {
362373
return c
363374
}
364375

376+
// WithSkuID returns a new ButtonComponent with the provided skuID
377+
func (c ButtonComponent) WithSkuID(skuID snowflake.ID) ButtonComponent {
378+
c.SkuID = skuID
379+
return c
380+
}
381+
365382
// AsEnabled returns a new ButtonComponent but enabled
366383
func (c ButtonComponent) AsEnabled() ButtonComponent {
367384
c.Disabled = false

events/interaction_events.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func (e *ApplicationCommandInteractionCreate) Modal(modalCreate discord.ModalCre
6161
return e.Respond(discord.InteractionResponseTypeModal, modalCreate, opts...)
6262
}
6363

64+
// Deprecated: Respond with a discord.ButtonStylePremium button instead.
6465
// PremiumRequired responds to the interaction with an upgrade button if available.
6566
func (e *ApplicationCommandInteractionCreate) PremiumRequired(opts ...rest.RequestOpt) error {
6667
return e.Respond(discord.InteractionResponseTypePremiumRequired, nil, opts...)
@@ -112,6 +113,7 @@ func (e *ComponentInteractionCreate) Modal(modalCreate discord.ModalCreate, opts
112113
return e.Respond(discord.InteractionResponseTypeModal, modalCreate, opts...)
113114
}
114115

116+
// Deprecated: Respond with a discord.ButtonStylePremium button instead.
115117
// PremiumRequired responds to the interaction with an upgrade button if available.
116118
func (e *ComponentInteractionCreate) PremiumRequired(opts ...rest.RequestOpt) error {
117119
return e.Respond(discord.InteractionResponseTypePremiumRequired, nil, opts...)
@@ -180,6 +182,7 @@ func (e *ModalSubmitInteractionCreate) DeferUpdateMessage(opts ...rest.RequestOp
180182
return e.Respond(discord.InteractionResponseTypeDeferredUpdateMessage, nil, opts...)
181183
}
182184

185+
// Deprecated: Respond with a discord.ButtonStylePremium button instead.
183186
// PremiumRequired responds to the interaction with an upgrade button if available.
184187
func (e *ModalSubmitInteractionCreate) PremiumRequired(opts ...rest.RequestOpt) error {
185188
return e.Respond(discord.InteractionResponseTypePremiumRequired, nil, opts...)

handler/interaction.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func (e *InteractionEvent) DeferUpdateMessage(opts ...rest.RequestOpt) error {
4040
return e.Respond(discord.InteractionResponseTypeDeferredUpdateMessage, nil, opts...)
4141
}
4242

43+
// Deprecated: Respond with a discord.ButtonStylePremium button instead.
4344
// PremiumRequired responds to the interaction with an upgrade button if available.
4445
func (e *InteractionEvent) PremiumRequired(opts ...rest.RequestOpt) error {
4546
return e.Respond(discord.InteractionResponseTypePremiumRequired, nil, opts...)

0 commit comments

Comments
 (0)