pub struct SectionBuilder { /* private fields */ }Expand description
Builds a section: 1-3 text displays next to an accessory — a button or a thumbnail.
The accessory is given to new, so it cannot be forgotten (D-204).
discord.js counterpart: SectionBuilder.
§Examples
use djs_builders::{ButtonBuilder, SectionBuilder};
let section = SectionBuilder::new(ButtonBuilder::secondary("settings").label("Settings"))
.text("**Notifications** are on")
.build()
.unwrap();
assert_eq!(section.children().len(), 1);Implementations§
Source§impl SectionBuilder
impl SectionBuilder
Sourcepub fn new(accessory: impl Into<Component>) -> Self
pub fn new(accessory: impl Into<Component>) -> Self
Creates a section with accessory (a button or a thumbnail) and no text yet; it needs
1-3 texts.
discord.js counterpart: new SectionBuilder().setButtonAccessory(…) /
setThumbnailAccessory(…).
Sourcepub fn text(self, content: impl Into<CompactString>) -> Self
pub fn text(self, content: impl Into<CompactString>) -> Self
Adds a text display showing content (markdown, 1-4000 characters).
discord.js counterpart: addTextDisplayComponents.
Sourcepub fn component(self, component: impl Into<Component>) -> Self
pub fn component(self, component: impl Into<Component>) -> Self
Adds a text display (a TextDisplayBuilder or a
djs-model value).
discord.js counterpart: addTextDisplayComponents.
Source§impl SectionBuilder
impl SectionBuilder
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 or modal.
discord.js counterpart: setId.
Sourcepub fn build(self) -> Result<Component, ValidationError>
pub fn build(self) -> Result<Component, ValidationError>
Checks the component (and what it contains) and returns it.
discord.js counterpart: toJSON of the component builders.
§Errors
The first ValidationError found; see the type docs
for the rules.
Sourcepub fn build_unchecked(self) -> Component
pub fn build_unchecked(self) -> Component
Returns the component without any check (D-180).
discord.js counterpart: toJSON of the component builders with validation off (disableValidators).