diff --git a/discord/component.go b/discord/component.go index 734597fd..f43611e7 100644 --- a/discord/component.go +++ b/discord/component.go @@ -234,15 +234,17 @@ const ( ButtonStyleSuccess ButtonStyleDanger ButtonStyleLink + ButtonStylePremium ) // NewButton creates a new ButtonComponent with the provided parameters. Link ButtonComponent(s) need a URL and other ButtonComponent(s) need a customID -func NewButton(style ButtonStyle, label string, customID string, url string) ButtonComponent { +func NewButton(style ButtonStyle, label string, customID string, url string, skuID snowflake.ID) ButtonComponent { return ButtonComponent{ Style: style, CustomID: customID, URL: url, Label: label, + SkuID: skuID, } } @@ -291,6 +293,14 @@ func NewLinkButton(label string, url string) ButtonComponent { } } +// NewPremiumButton creates a new ButtonComponent with ButtonStylePremium & the provided parameters +func NewPremiumButton(skuID snowflake.ID) ButtonComponent { + return ButtonComponent{ + Style: ButtonStylePremium, + SkuID: skuID, + } +} + var ( _ Component = (*ButtonComponent)(nil) _ InteractiveComponent = (*ButtonComponent)(nil) @@ -301,6 +311,7 @@ type ButtonComponent struct { Label string `json:"label,omitempty"` Emoji *ComponentEmoji `json:"emoji,omitempty"` CustomID string `json:"custom_id,omitempty"` + SkuID snowflake.ID `json:"sku_id,omitempty"` URL string `json:"url,omitempty"` Disabled bool `json:"disabled,omitempty"` } @@ -362,6 +373,12 @@ func (c ButtonComponent) WithURL(url string) ButtonComponent { return c } +// WithSkuID returns a new ButtonComponent with the provided skuID +func (c ButtonComponent) WithSkuID(skuID snowflake.ID) ButtonComponent { + c.SkuID = skuID + return c +} + // AsEnabled returns a new ButtonComponent but enabled func (c ButtonComponent) AsEnabled() ButtonComponent { c.Disabled = false diff --git a/events/interaction_events.go b/events/interaction_events.go index 2f04e250..a53a6588 100644 --- a/events/interaction_events.go +++ b/events/interaction_events.go @@ -61,6 +61,7 @@ func (e *ApplicationCommandInteractionCreate) Modal(modalCreate discord.ModalCre return e.Respond(discord.InteractionResponseTypeModal, modalCreate, opts...) } +// Deprecated: Respond with a discord.ButtonStylePremium button instead. // PremiumRequired responds to the interaction with an upgrade button if available. func (e *ApplicationCommandInteractionCreate) PremiumRequired(opts ...rest.RequestOpt) error { return e.Respond(discord.InteractionResponseTypePremiumRequired, nil, opts...) @@ -112,6 +113,7 @@ func (e *ComponentInteractionCreate) Modal(modalCreate discord.ModalCreate, opts return e.Respond(discord.InteractionResponseTypeModal, modalCreate, opts...) } +// Deprecated: Respond with a discord.ButtonStylePremium button instead. // PremiumRequired responds to the interaction with an upgrade button if available. func (e *ComponentInteractionCreate) PremiumRequired(opts ...rest.RequestOpt) error { return e.Respond(discord.InteractionResponseTypePremiumRequired, nil, opts...) @@ -180,6 +182,7 @@ func (e *ModalSubmitInteractionCreate) DeferUpdateMessage(opts ...rest.RequestOp return e.Respond(discord.InteractionResponseTypeDeferredUpdateMessage, nil, opts...) } +// Deprecated: Respond with a discord.ButtonStylePremium button instead. // PremiumRequired responds to the interaction with an upgrade button if available. func (e *ModalSubmitInteractionCreate) PremiumRequired(opts ...rest.RequestOpt) error { return e.Respond(discord.InteractionResponseTypePremiumRequired, nil, opts...) diff --git a/handler/interaction.go b/handler/interaction.go index 745c037b..3d2c58f7 100644 --- a/handler/interaction.go +++ b/handler/interaction.go @@ -40,6 +40,7 @@ func (e *InteractionEvent) DeferUpdateMessage(opts ...rest.RequestOpt) error { return e.Respond(discord.InteractionResponseTypeDeferredUpdateMessage, nil, opts...) } +// Deprecated: Respond with a discord.ButtonStylePremium button instead. // PremiumRequired responds to the interaction with an upgrade button if available. func (e *InteractionEvent) PremiumRequired(opts ...rest.RequestOpt) error { return e.Respond(discord.InteractionResponseTypePremiumRequired, nil, opts...)