pub struct PremiumButtonBuilder { /* private fields */ }Expand description
Builds a premium button,
which lets users buy one of your app’s SKUs; created by ButtonBuilder::premium.
Discord shows the SKU’s name, icon and price on it, so it has no label, emoji or
custom_id, and clicking it sends no interaction. Its own type (D-202) makes adding a
label a compile-time error.
discord.js counterpart: ButtonBuilder with ButtonStyle.Premium.
§Examples
use djs_builders::{ActionRowBuilder, ButtonBuilder};
use djs_model::id::SkuId;
let row = ActionRowBuilder::new()
.component(ButtonBuilder::premium(SkuId::new(1_088_510_058_284_990_888)))
.build()
.unwrap();
assert_eq!(row.children().len(), 1);Implementations§
Source§impl PremiumButtonBuilder
impl PremiumButtonBuilder
Sourcepub fn disabled(self, disabled: bool) -> Self
pub fn disabled(self, disabled: bool) -> Self
Sets whether the button is greyed out and cannot be clicked.
discord.js counterpart: setDisabled.
Sourcepub fn id(self, id: i32) -> Self
pub fn id(self, id: i32) -> Self
Sets the component’s numeric identifier (Discord generates one otherwise); it must be unique in the message.
discord.js counterpart: setId.
Sourcepub fn build(self) -> Result<Component, ValidationError>
pub fn build(self) -> Result<Component, ValidationError>
Returns the button as a [Component]. It returns a Result like every other builder
(D-179), so code can treat all buttons alike.
discord.js counterpart: ButtonBuilder#toJSON with setSKUId.
§Errors
None: a premium button has nothing that can break a rule.
Sourcepub fn build_unchecked(self) -> Component
pub fn build_unchecked(self) -> Component
Returns the button as a [Component] (D-180; the same as build).
discord.js counterpart: ButtonBuilder#toJSON with setSKUId.